Building Data-Driven Web Apps with Flask and SQLAlchemy Transcripts
Chapter: Deployment
Lecture: Concept: uWSGI

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's quickly look at what we had to do to get our code running under uWSGI. Basically, what we had to do is come up with this command
0:07 that would just launch uWSGI. So this exec start command here notice that's actually one line that's wrapping around.
0:14 It's basically the two lines there are one individual line in a file. So, we're going to go and run the uWSGI out of our virtual environment.
0:23 We're going to say the home is the virtual environment so it knows to use that for Python. Master mode, we want four processes, two threads.
0:29 I suspect we could have actually a lot more threads per process. Listen on HTTP port 5000. Set the Python path to where our project is.
0:38 And then we created the wsgi.py file it just imported the app and we're going to mount / go into the wsgi module, get the app variable out
0:47 and that's what Flask is going to use here. And that's it. It's off to the races, it works great. Also set the runtime directory.
0:54 I think the final / there is super important. I think if you omit it it reports it as an error. So we just set this up and this is a systemd unit file
1:03 and it just runs this command and keeps it running if there were some reason it crashes. That's all we got to do
1:09 to make sure that our app runs under uWSGI. But remember, it's best to take that exec start command run it separately, make sure it works
1:17 and then come back and try to set it up as this daemon process here.


Talk Python's Mastodon Michael Kennedy's Mastodon