Skip to content

Instantly share code, notes, and snippets.

@wynemo
Created April 27, 2012 06:36
Show Gist options
  • Save wynemo/2506627 to your computer and use it in GitHub Desktop.
Save wynemo/2506627 to your computer and use it in GitHub Desktop.
uwsgi web.py supervisor ubuntu12.04
#partial config
server {
listen 80;
server_name -;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
uwsgi_param UWSGI_PYHOME /home/user/webpy_project_dir/env;
uwsgi_param UWSGI_SCRIPT wsgi;
uwsgi_param UWSGI_CHDIR /home/user/webpy_project_dir/;
}
}
# https://gist.github.com/2422960/ copyright by orignal author
# Supervisord auto-start
#
# description: Auto-starts supervisord
# processname: supervisord
# pidfile: /var/run/supervisord.pid
SUPERVISORD=/usr/local/bin/supervisord
SUPERVISORCTL=/usr/local/bin/supervisorctl
case $1 in
start)
echo -n "Starting supervisord: "
$SUPERVISORD
echo -n "supervisord started"
echo
;;
stop)
echo -n "Stopping supervisord: "
$SUPERVISORCTL shutdown
echo
;;
restart)
echo -n "Restarting supervisord: "
$SUPERVISORCTL reload
echo
;;
esac
;partial supervisord.conf
[program:app1]
command=/home/user_name/uwsgi-0.9.8.6/uwsgi
--uid user_name
-x /home/user_name/webpy_uwsgi.xml
--vhost
user=user_name
autostart=true
autorestart=true
stdout_logfile=/sites/app1/logs/app1log.log
stderr_logfile=/sites/app1/logs/app1err.log
stopsignal=QUIT

####install pip and virtualenv

$ sudo aptitude install python-setuptools python-pip
$ sudo pip install virtualenv

#easy_install
#easy_install pip
#pip install everything
#sudo pip install web.py

####compile uwsgi

$ sudo aptitude install python26-dev gcc
$ wget http://projects.unbit.it/downloads/uwsgi-1.1.2.tar.gz
$ tar zxvf uwsgi-1.1.2.tar.gz
$ python uwsgiconfig.py --build

####virtualenv and uwsgi stuff

$ cd webpy_project_dir
$ virtualenv --no-site-packages env
$ virtualenv --relocatable env
$ . env/bin/activate

$ mkdir env/src

$ wget http://webpy.org/static/web.py-0.36.tar.gz

$ tar zxvf web.py-0.36.tar.gz

$ python setup.py install

$ pip install web.py
$ deactivate
$ vim webpy_uwsgi.xml
$ ~/uwsgi-1.1.2/uwsgi --uid user -x ~/webpy_uwsgi.xml --vhost

####nginx config

$ sudo aptitude install nginx
$/etc/init.d/nginx start

####supervisor config

$ sudo pip install supervisor
# cp /usr/local/lib/python2.7/dist-packages/supervisor/skel/sample.conf  /etc/supervisord.conf  #copy sample config
# supervisord
# vim /etc/supervisord.conf
# supervisorctl update   #after /etc/supervisord.conf
# supervisorctl start app1
# supervisorctl stop app1

###add supervisor to /etc/init.d/

# cp supervisord.sh /etc/init.d/supervisor
# chmod +x /etc/init.d/supervisor
# /usr/sbin/update-rc.d -f supervisor defaults
<uwsgi>
<socket>127.0.0.1:9090</socket>
<master/>
<processes>2</processes>
<max-requests>1000</max-requests>
</uwsgi>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment