Skip to content

Instantly share code, notes, and snippets.

@rkusa
Last active September 20, 2016 10:29
Show Gist options
  • Save rkusa/5487b5987c3af658f86ec650ff14114a to your computer and use it in GitHub Desktop.
Save rkusa/5487b5987c3af658f86ec650ff14114a to your computer and use it in GitHub Desktop.
unicorn rc.d script
upstream gunicorn {
server unix:/tmp/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://gunicorn;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
#!/bin/sh
. /etc/rc.subr
name=myapp
rcvar=myapp_enable
myapp_chdir=/usr/local/www
pidfile="/var/run/${name}.pid"
logfile="/var/log/${name}.log"
command="/usr/local/bin/python3.5"
command_args="/usr/local/bin/gunicorn --daemon --pid=$pidfile --log-file=$logfile --workers 3 --bind 'unix:/tmp/gunicorn.sock' --group www --user www myapp.wsgi"
load_rc_config $name
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment