I would like to deploy a Flask (python) app on Heroku, I did it before without any problem . But now, I don't know what is the problem .
The problem is here, When I enter the following command to test the local server :
foreman start
I have this error :
foreman start
12:01:53 web.1 | started with pid 6055
12:01:53 web.1 | 2013-12-25 12:01:53 [6058] [INFO] Starting gunicorn 18.0
12:01:53 web.1 | 2013-12-25 12:01:53 [6058] [INFO] Listening at: http://0.0.0.0:5000 (6058)
12:01:53 web.1 | 2013-12-25 12:01:53 [6058] [INFO] Using worker: sync
12:01:53 web.1 | 2013-12-25 12:01:53 [6063] [INFO] Booting worker with pid: 6063
12:01:53 web.1 | 2013-12-25 12:01:53 [6063] [ERROR] Exception in worker process:
12:01:53 web.1 | Traceback (most recent call last):
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
12:01:53 web.1 | worker.init_process()
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
12:01:53 web.1 | self.wsgi = self.app.wsgi()
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
12:01:53 web.1 | self.callable = self.load()
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
12:01:53 web.1 | return self.load_wsgiapp()
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
12:01:53 web.1 | return util.import_app(self.app_uri)
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
12:01:53 web.1 | __import__(module)
12:01:53 web.1 | ImportError: Import by filename is not supported.
12:01:53 web.1 | Traceback (most recent call last):
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
12:01:53 web.1 | worker.init_process()
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
12:01:53 web.1 | self.wsgi = self.app.wsgi()
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
12:01:53 web.1 | self.callable = self.load()
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
12:01:53 web.1 | return self.load_wsgiapp()
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
12:01:53 web.1 | return util.import_app(self.app_uri)
12:01:53 web.1 | File "/home/myhome/myApp/venv/local/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
12:01:53 web.1 | __import__(module)
12:01:53 web.1 | ImportError: Import by filename is not supported.
12:01:53 web.1 | 2013-12-25 12:01:53 [6063] [INFO] Worker exiting (pid: 6063)
12:01:53 web.1 | 2013-12-25 12:01:53 [6058] [INFO] Shutting down: Master
12:01:53 web.1 | 2013-12-25 12:01:53 [6058] [INFO] Reason: Worker failed to boot.
12:01:53 web.1 | exited with code 3
12:01:53 system | sending SIGTERM to all processes
SIGTERM received
My Procfile is :
web: gunicorn app/route:app
And I am using this main :
if __name__ == '__main__':
import logging
from logging.handlers import RotatingFileHandler
handler = RotatingFileHandler('foo.log', maxBytes=10000, backupCount=1)
handler.setLevel(logging.INFO)
app.logger.addHandler(handler)
if TODAY != cache.config['CACHE_ARGS'] :
with app.app_context():
cache.clear()
port = int(os.environ.get('PORT', 33507))
app.run(debug = True, host='0.0.0.0', port=port)
When I run the app on the browser (0.0.0.0:33507) it works perfectly .