use helpers & uwsgi. Enable multi instance
This commit is contained in:
4
conf/app.src
Normal file
4
conf/app.src
Normal file
@@ -0,0 +1,4 @@
|
||||
SOURCE_URL=https://github.com/mozilla-services/syncserver/archive/1.5.2.zip
|
||||
SOURCE_SUM=2ce201626b720589d1916972cac0cfdec27db42992924b7fb7fef5ae92a148d8
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
75
conf/ffsync
75
conf/ffsync
@@ -1,75 +0,0 @@
|
||||
#!/bin/bash
|
||||
# /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/sync.lock
|
||||
conffile=${SYNC_HOME}/syncserver.ini
|
||||
GUNICORN=${SYNC_HOME}/local/bin/gunicorn
|
||||
GUNICORN_ARGS="--paste $conffile --access-logfile /var/log/ffsync.log --daemon -p $pidfile"
|
||||
|
||||
start () {
|
||||
echo -n "Starting $prog"
|
||||
start-stop-daemon --start -c ${SYNC_USER} --exec $GUNICORN -- $GUNICORN_ARGS
|
||||
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}
|
||||
}
|
||||
|
||||
status(){
|
||||
if [[ -f ${pidfile} ]]; then
|
||||
echo "Status: running."
|
||||
exit 0;
|
||||
else
|
||||
echo "Status: not running."
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $prog {start|stop|restart|help}"
|
||||
RETVAL=2
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
@@ -1,9 +0,0 @@
|
||||
"/var/log/ffsync.log" {
|
||||
copytruncate
|
||||
daily
|
||||
rotate 7
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
location PATHTOCHANGE {
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
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 __PATH__ {
|
||||
# Path to source
|
||||
alias __FINALPATH__/ ;
|
||||
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
include uwsgi_params;
|
||||
# Needed for long running operations in admin interface
|
||||
uwsgi_read_timeout 3600;
|
||||
uwsgi_param SCRIPT_NAME __PATH__;
|
||||
uwsgi_modifier1 30;
|
||||
uwsgi_pass unix://__FINALPATH__/socket;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
[server:main]
|
||||
use = egg:gunicorn
|
||||
host = 0.0.0.0
|
||||
port = 5000
|
||||
workers = 1
|
||||
timeout = 30
|
||||
[uwsgi]
|
||||
plugins = python
|
||||
master = true
|
||||
protocol = uwsgi
|
||||
socket = __FINALPATH__/socket
|
||||
virtualenv = __FINALPATH__/local
|
||||
wsgi-file = __FINALPATH__/syncserver.wsgi
|
||||
python-path = __FINALPATH__/local
|
||||
enable-threads = true
|
||||
close-on-exec = true
|
||||
umask = 0660
|
||||
|
||||
[app:main]
|
||||
use = egg:syncserver
|
||||
@@ -11,10 +16,10 @@ use = egg:syncserver
|
||||
[syncserver]
|
||||
# This must be edited to point to the public URL of your server,
|
||||
# i.e. the URL as seen by Firefox.
|
||||
public_url = https://ynhbaseurl/
|
||||
public_url = https://__DOMAIN____PATH__
|
||||
|
||||
# This defines the database in which to store all server data.
|
||||
sqluri = pymysql://yunouser:yunopass@localhost/yunobase
|
||||
sqluri = pymysql://__DB_USER__:__DB_PWD__@localhost/__DB_NAME__
|
||||
|
||||
# This is a secret key used for signing authentication tokens.
|
||||
# It should be long and randomly-generated.
|
||||
@@ -23,7 +28,7 @@ sqluri = pymysql://yunouser:yunopass@localhost/yunobase
|
||||
# head -c 20 /dev/urandom | sha1sum
|
||||
#
|
||||
# If not specified then the server will generate a temporary one at startup.
|
||||
secret = changesecret
|
||||
secret = __SECRET__
|
||||
|
||||
# Set this to "false" to disable new-user signups on the server.
|
||||
# Only request by existing accounts will be honoured.
|
||||
@@ -35,11 +40,10 @@ allow_new_users = true
|
||||
# details from public_url. This could have security implications if e.g.
|
||||
# you tell the app that it's on HTTPS but it's really on HTTP, so it should
|
||||
# only be used as a last resort and after careful checking of server config.
|
||||
force_wsgi_environ = true
|
||||
force_wsgi_environ = false
|
||||
|
||||
# Uncomment and edit the following to use a local BrowserID verifier
|
||||
# rather than posting assertions to the mozilla-hosted verifier.
|
||||
# Audiences should be set to your public_url without a trailing slash.
|
||||
#[browserid]
|
||||
#backend = tokenserver.verifiers.LocalVerifier
|
||||
#audiences = https://localhost:5000
|
||||
|
||||
18
conf/systemd.service
Normal file
18
conf/systemd.service
Normal file
@@ -0,0 +1,18 @@
|
||||
[Unit]
|
||||
Description=uWSGI instance for __APP__
|
||||
Requires=network.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory=__FINALPATH__
|
||||
ExecStart=/usr/bin/uwsgi \
|
||||
--ini __FINALPATH__/syncserver.ini \
|
||||
--socket __FINALPATH__/socket
|
||||
Restart=always
|
||||
StandardError=syslog
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user