I was wondering where to deploy the application made with Flask, and it is written in Official deployment document. I decided to try it with Heroku and dotCloud. So, Heroku didn't have much addiction to Flask in Documentation, but I was addicted to dotCloud, so I made a note. Oh, it's not that Heroku is good and dotCloud is bad! Rather, I want to operate it with dotCloud.
The documentation on the Flask side
That's why Flask is arranged for WSGI with basic WSGI. While reading the former, the actual work feels like the latter.
However, since I did Heroku first, it wasn't configured to be written in the package __init__.py
. Create a directory of packages and move ʻapp.py-like things to
init.py. Then write
wsgi.py. If you didn't specify approot in
dotcloud.yml, put
wsgi.py` in the root. Please note that this is different from the former document. Well, even the former is at the beginning
Your WSGI callable should be named “application”, be located in a “wsgi.py” file, itself located at the top directory of the service.
Although it is written, approot is specified in the subsequent procedure explanation.
So, it starts to work, but with this, the sample stops. The app I was trying to deploy used the twitter API, so I have to put the key. I definitely don't want to put the key in SCM. On Heroku, I set it with config: add. You can now read it from os.environ.
For dotCloud, do var set. The method of specification was almost the same as Heroku, so the code remains the same ... but it doesn't work at all! If you read the documentation carefully, you need to read environment.json. I rewrote the code to read from here.
With this, I was able to bring it to the point where it could move. I haven't touched the database-related part yet.
I feel like I'm not so addicted to it, but he solved the addiction.
dotcloud logs appname.www
The most important point is that it was difficult because I didn't know at first. I found out that there was heroku logs in Heroku's Python Tutorial, but it seems that dotCloud didn't have it, so I have to find it myself. had. That's the Consulting Logs (http://docs.dotcloud.com/guides/logs/) in Platform Guides to the left of Documentation. It's been a lot of progress since I found this. In fact, when I ran it without setting environment variables and got an error, it took me a while without knowing the cause. When I look at the log, it feels like that. If you get stuck, look at the log!
Recommended Posts