RESTful and HTTP APIs in Pyramid Transcripts
Chapter: Deploying your REST service to DigitalOcean on Ubuntu
Lecture: Concepts: Deployment
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Let's review the various steps we had to take to configure our servers. We installed a bunch of things via aptitude
0:09
in order to get our server ready to run what we needed, we installed μwsgi, we installed Python 3,
0:14
we installed nginx and a bunch of other stuff along there, we stalled the get, command, line tools and so on.
0:21
So that's all in that setup_script.txt, I said txt not sh because you really aren't supposed to run the whole thing
0:28
there's a few steps that require manual intervention and so on. I guess you could run it once and just sort of realize
0:35
ok, here's where I enter my username and password for github and things like that
0:39
but however you want to use it, you can make it a full on proper script; there's a bunch of stuff in there that we'd ran that I'm not showing here,
0:46
but these are the key configurations for the various pieces set up by those steps. So first of all, in order, we saw in order to run μwsgi,
0:54
by pointing it at our configuration file, it needs a μwsgi section so this goes into production.ini, and see the μwsgi section
1:01
what you want to listen to that could be a socket instead of http, where's the working directory,
1:07
how many processes, where to log to, things like that. So, make sure this just goes at the beginning or really anywhere I suspect,
1:14
but you can put at the beginning of your production,ini. Then, we have to register a μwsgi as a service, using system d
1:22
so here we gave it like a description name and a target so we can run as soon as sys log is going,
1:28
and then the execution path is to run μwsgi with any -paste option pointing at production.ini, and giving it the working directory.
1:36
Other than that, you can pretty much just say this is just standard a system d service file; in order for this to do anything,
1:43
we have to copy it to /etc/systemd/system and then you could just say refer to it as auto_service
1:51
if you used the service extension on the file you can omit it when you're interacting with it on the command line.
1:57
The other thing in addition to μwsgi that we used is nginx. So here we set up a configuration for nginx, we said
2:04
I want you to listen to auto_service.talkpython.fm you saw that I removed the default website, so you could also go to this by ip address,
2:14
and it'll just use the one and only thing it has this, but you can have many different servers and many different server names
2:20
and things like that, you can just have a different server name here and it'll only listen
2:25
at that point to that particular domain name, not just the ip address. So we're listening on port 80, we're mapping static files
2:32
with a year-long cash to where the static files go, again we copy this to etc/nginx/sites-enabled
2:39
and then there was some more stuff after the server set up and the static we set the location for \ onward just
2:45
pass the url off to my application I am configuring below which is to basically do a little bit of setup on headers
2:54
and gzip for speed, and then say we're just going to do a proxy pass over to μwsgi, to the main masterpiece
3:01
running at port 8999 locally, could be another machines actually, but right now it's locally, and then that thing will figure out which sub process
3:10
is going to actually, work or process is going to handle that individual request There you have it, we have our service running very nicely
3:17
on a nice, cheap, high performance, Digital Ocean server for five bucks a month.