I have a Flask app, written with the Cloud9 IDE. I run it locally with: "python manage.py runserver" in the Terminal. This is then triggered:
manager.add_command('runserver', Server(
use_debugger = True,
use_reloader = True,
host = os.getenv('IP', '0.0.0.0'),
port = int(os.getenv('PORT', 5000))
)
)
This piece of code is located in the manage.py file.
Now I want to run it with Heroku. I followed their tutorial entirely. I just didn't know what my Procfile should be. I wrote it like so:
web: gunicorn manage:runserver
Pushing the git etc. all seems to work fine. When I type: "heroku ps:scale web=1", I get this in my Terminal:
Scaling dynos... done, now running web at 1:Free.
When I type "Heroku open", I get this error:
Opening fierce-spire-3069... xprop: unable to open display ''
xprop: unable to open display ''
/usr/bin/xdg-open: 461: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 461: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 461: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 461: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'https://fierce-spire-3069.herokuapp.com/'
done
So, my app can't be opened.. When I open it with the Heroku site, I get an error message. This is what I've found in the logs:
2015-12-29T20:15:06.399443+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fierce-spire-3069.herokuapp.com request_id=c5d76e45-5d56-45f4-a2bc-75bd7fc08b7f fwd="81.82.128.183" dyno= connect= service= status=503 bytes=
What am I doing wrong?
EDIT
I changed my Profile to this:
web: python manage.py runserver "0.0.0.0:5000"
The above error message in the Heroku logs is gone, but there is a new one:
2015-12-29T21:30:37.938957+00:00 app[web.1]: from tsb import app
2015-12-29T21:30:37.938955+00:00 app[web.1]: File "manage.py", line 7, in <module>
2015-12-29T21:30:37.939002+00:00 app[web.1]: ImportError: No module named tsb
This refers to this part of the manage.py code:
from tsb import app
"tsb" is the folder in which all of my project files are stored, it's the project folder. How come this couldn't be imported?
You aren't using gunicorn correctly. The basic usage is
$ gunicorn [OPTIONS] APP_MODULE
This is what you need to use in Procfile
.
web: gunicorn [OPTIONS] APP_MODULE
I can't tell you what options to use. You can find that in Heroku's gunicorn documentation . The important thing here is APP_MODULE
.
It looks like your application instance is being exposed through manage.py
, so you'd want to use
web: gunicorn manage
If you try this, however, it'll probably fail. By default gunicorn will look for something named application
inside APP_MODULE
. Your application seems to be named manager
. That means you need
web: gunicorn manage:manager
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.