diff --git a/.gitignore b/.gitignore index f346b88f91..c851fc6495 100644 --- a/.gitignore +++ b/.gitignore @@ -16,17 +16,29 @@ settings.py.mysql settings.py.sqlite secret_key.py run-seahub.sh + +# setenv setenv.sh +setenv*.sh + pylintrc .DS_Store *.mo media/CACHE media/custom + +# media/avatars media/avatars/* !media/avatars/default-non-register.jpg !media/avatars/default.png !media/default.jpg !media/groups/default.jpg + +# bin/ +bin/* +!bin/start.template +!bin/restart.template + static/scripts/dist logs/ mysite.pid diff --git a/bin/restart.template b/bin/restart.template new file mode 100755 index 0000000000..45d9f044d6 --- /dev/null +++ b/bin/restart.template @@ -0,0 +1,33 @@ +#!/bin/bash + + +PROJDIR="/home/ubuntu/seahub" +PIDFILE="$PROJDIR/mysite.pid" + +#kill -HUP `cat -- $PIDFILE` + +cd $PROJDIR + +if [ -f $PIDFILE ]; then + echo "Killing seahub python processes ..." + PID=`cat -- $PIDFILE` + echo "Parent process: $PID" + echo "Child processes:" `pgrep -P $PID` + + kill `cat -- $PIDFILE` + rm -f -- $PIDFILE + + sleep 5 +fi + +echo "" +echo "Starting seahub gunicorn ..." +./start.template +sleep 2 + +if [ -f $PIDFILE ]; then + echo "Done." + PID=`cat -- $PIDFILE` + echo "New seahub parent process: $PID" + echo "Child processes:" `pgrep -P $PID` +fi diff --git a/bin/start.template b/bin/start.template new file mode 100755 index 0000000000..bfa466f296 --- /dev/null +++ b/bin/start.template @@ -0,0 +1,18 @@ +#!/bin/bash + +NAME=Seahub +DJANGODIR=/home/ubuntu/seahub/ # Django project directory +PID_FILE=${DJANGODIR}mysite.pid +NUM_WORKERS=3 # how many worker processes should Gunicorn spawn +DJANGO_SETTINGS_MODULE=seahub.settings # which settings file should Django use +DJANGO_WSGI_MODULE=seahub.wsgi:application # WSGI module name + +cd $DJANGODIR +source ~/.virtualenvs/6.3/bin/activate # Activate the virtual environment +. setenv.sh # Set ccnet/seafiel env, and related python path + +export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE +export LANG=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 +export LC_LANG=en_US.UTF-8 +gunicorn ${DJANGO_WSGI_MODULE} --workers $NUM_WORKERS --log-level=debug --access-logfile=/tmp/gunicorn-access.log --error-logfile=/tmp/gunicorn-error.log --pid=${PID_FILE} --daemon --preload