Building data-driven web apps with Flask and SQLAlchemy Transcripts
Lecture: Concept: uWSGI
0:00 Let's quickly look at what we had to do
0:01 to get our code running under uWSGI.
0:04 Basically, what we had to do is come up with this command
0:06 that would just launch uWSGI.
0:08 So this exec start command here
0:10 notice that's actually one line that's wrapping around.
0:13 It's basically the two lines there are one individual line
0:17 in a file. So, we're going to go and run the uWSGI
0:20 out of our virtual environment.
0:22 We're going to say the home is the virtual environment
0:24 so it knows to use that for Python.
0:26 Master mode, we want four processes, two threads.
0:28 I suspect we could have actually
0:29 a lot more threads per process.
0:31 Listen on HTTP port 5000.
0:34 Set the Python path to where our project is.
0:37 And then we created the wsgi.py file
0:41 it just imported the app
0:42 and we're going to mount /
0:43 go into the wsgi module, get the app variable out
0:46 and that's what Flask is going to use here.
0:49 And that's it. It's off to the races, it works great.
0:52 Also set the runtime directory.
0:53 I think the final / there is super important.
0:56 I think if you omit it it reports it as an error.
0:58 So we just set this up and this is a systemd unit file
1:02 and it just runs this command and keeps it running
1:05 if there were some reason it crashes.
1:07 That's all we got to do
1:08 to make sure that our app runs under uWSGI.
1:10 But remember, it's best to take that exec start command
1:13 run it separately, make sure it works
1:16 and then come back
1:17 and try to set it up as this daemon process here.