firefox sync with gunicorn

This commit is contained in:
Adrien Beudin
2015-02-13 18:10:02 +01:00
parent 23a0192c74
commit c53e73afd6
11 changed files with 201 additions and 25 deletions

64
conf/ffsync Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/bash -x
# /etc/init.d/sync
# version 0.1 2013-03-12 (YYYY-MM-DD)
### BEGIN INIT INFO
# Provides: sync
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Mozilla Sync server
# Description: Starts the mozilla sync server
### END INIT INFO
# Source function library.
#. /etc/rc.d/init.d/functions
prog=sync
SYNC_USER=ffsync
SYNC_HOME=/opt/yunohost/ffsync
CPU_COUNT=2
pidfile=/tmp/sync.pid
lockfile=/var/run/mozilla/sync.lock
conffile=${SYNC_HOME}/syncserver.ini
GUNICORN=${SYNC_HOME}/local/bin/gunicorn_paster
GUNICORN_ARGS="--access-logfile /var/log/ffsync.log --daemon -p $pidfile"
#INVOCATION="$GUNICORN $GUNICORN_ARGS $conffile"
start () {
echo -n "Starting $prog"
start-stop-daemon --start -c ${SYNC_USER} --exec $GUNICORN -- $GUNICORN_ARGS $conffile
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo "Stopping $prog"
start-stop-daemon --stop --quiet --oknodo --pidfile ${pidfile}
#log_end_msg $?
rm -f ${pidfile}
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart|help}"
RETVAL=2
esac
exit $RETVAL

View File

@@ -2,13 +2,14 @@ location PATHTOCHANGE {
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
try_files $uri @ffsync;
}
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_read_timeout 120;
proxy_connect_timeout 10;
proxy_pass http://127.0.0.1:5000/;
location @ffsync {
uwsgi_pass unix:///run/uwsgi/app/ffsync/socket;
include uwsgi_params;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View File

@@ -1,7 +1,9 @@
[server:main]
use = egg:Paste#http
host = 0.0.0.0
use = egg:gunicorn
host = 127.0.0.1
port = 5000
workers = 2
timeout = 60
[app:main]
use = egg:syncserver