New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Gunicorn/Nginx #73
Conversation
listen *:80; | ||
server_name _; | ||
|
||
root {{ app_home }}/static; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my education, what does root
do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sets the static files directory as the web root for this site configuration. This works with try_files
to determine if a file exists before passing the request through the proxy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. The static directory isn't the right directory to serve static assets from though. static/
is where I intend gulp to put them into, once we wire it in place, but they'll get collected into assets/
(though an open PR of mine changes this to the more obviously named collected_static/
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this needs to change to /assets
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was a little unclear. My PR is merged, so this should change to collected_static/
+1 I was on the fence about this, but I've been convinced. BTW, you should probably change the README to remove references to |
user: name=nyc-trees | ||
system=yes | ||
createhome=no | ||
shell=/bin/false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're curious, I took a look at the desirability of setting shell=
to /bin/false
, /dev/null
, and /sbin/nologin
, because I'd seen /dev/null
here in the past.
http://serverfault.com/questions/519215/what-is-the-difference-between-sbin-nologin-and-bin-false
Didn't come up with anything that is best by test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some good detail in there.
I've been using /bin/false
for a while and was only recently (in the past few years) exposed to /sbin/nologin
. My decision to go with /bin/false
has a lot to do with its use by existing UNIX accounts:
vagrant@app:~$ cat /etc/passwd | grep false
syslog:x:101:104::/home/syslog:/bin/false
messagebus:x:102:106::/var/run/dbus:/bin/false
landscape:x:103:109::/var/lib/landscape:/bin/false
pollinate:x:105:1::/var/cache/pollinate:/bin/false
statd:x:106:65534::/var/lib/nfs:/bin/false
puppet:x:107:112:Puppet configuration management daemon,,,:/var/lib/puppet:/bin/false
ntp:x:108:113::/home/ntp:/bin/false
colord:x:109:115:colord colour management daemon,,,:/var/lib/colord:/bin/false
nyc-trees:x:999:999::/home/nyc-trees:/bin/false
That said, there are several that make use of /usr/sbin/nologin
too. ¯\_(ツ)_/¯
+1 |
Whoops, I intended to push a branch of the same name to my (not yet existent) fork, and I instead pushed commits onto @hectcastro's branch. Sorry for the inconvenience. If we end up keeping them, we can just merge. If not, I can do some git cleaning. I pulled down this branch and everything appeared to work, but some of the gunicorn options (including ones that were suggested by me) are not supported by version 1.19, and/or did not produce the desired affect. I updated the config and also moved it to a new file. I can now use gunicorn interactively by running the included script. |
Does it make sense to keep the Gunicorn configuration trim and within the Upstart script leaving |
@hectcastro I can't speak for other developers, but I use the Python debugger basically every single day. Its not something I reserve for "hard" situations. |
@hectcastro There's nothing wrong with that idea, because it essentially reflects what we've been doing already on other projects. The consequence, at least for me, is that I never use the |
I use PyCharm for debugging, and it looks like it's workable with gunicorn. (http://stackoverflow.com/a/17191033/362702) |
+1 |
This changeset makes Gunicorn the application server for Django across environments. In addition, Upstart handles launching the Gunicorn worker pool and Nginx reverse proxies requests to it. It is also important to note that when the application is provisioned in the development and test environments, the Gunicorn `--reload` flag is used. This provides automatic Gunicorn worker reloads when code changes occur. I tested application reloading by making source code changes via the Vagrant shared folder and worker PIDs changed as expected. For more discussion, see: #71
In addition, I set `timeout` to 30 minutes and lowered it to 60 in the `else` because the ELB terminates requests at 60 seconds anyway.
This will make it easier to use the same config in multiple places
Ok, I'm pretty sure this is ready, with a +1 and no further objection. I'm going to rebase, clean and merge shortly. |
+1 |
@azavea-bot rebuild |
404a5a3
to
807a238
Compare
Add support for Gunicorn/Nginx
This changeset makes Gunicorn the application server for Django across environments. In addition, Upstart handles launching the Gunicorn worker pool and Nginx reverse proxies requests to it.
It is also important to note that when the application is provisioned in the development and test environments, the Gunicorn
--reload
flag is used. This provides automatic Gunicorn worker reloads when code changes occur. I tested application reloading by making source code changes via the Vagrant shared folder and worker PIDs changed as expected.For more discussion, see: #71