move gunicorn configuration from init script to config file
This commit is contained in:
parent
7ec1e9f6da
commit
29204b6fb5
5 changed files with 29 additions and 16 deletions
4
ctl
4
ctl
|
@ -27,6 +27,9 @@ if [ "$action" = "init" ]; then
|
||||||
done
|
done
|
||||||
cd ${BASE}
|
cd ${BASE}
|
||||||
./bin/pip install -r requirements.txt
|
./bin/pip install -r requirements.txt
|
||||||
|
if [ ! -e pandora/gunicorn_config.py ]; then
|
||||||
|
cp pandora/gunicorn_config.py.in pandora/gunicorn_config.py
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [ `whoami` != 'root' ]; then
|
if [ `whoami` != 'root' ]; then
|
||||||
|
@ -41,6 +44,7 @@ if [ "$action" = "install" ]; then
|
||||||
cp $BASE/etc/systemd/*.service /lib/systemd/system/
|
cp $BASE/etc/systemd/*.service /lib/systemd/system/
|
||||||
cp $BASE/etc/tmpfiles.d/pandora.conf /usr/lib/tmpfiles.d/
|
cp $BASE/etc/tmpfiles.d/pandora.conf /usr/lib/tmpfiles.d/
|
||||||
systemd-tmpfiles --create /usr/lib/tmpfiles.d/pandora.conf >/dev/null || true
|
systemd-tmpfiles --create /usr/lib/tmpfiles.d/pandora.conf >/dev/null || true
|
||||||
|
systemctl daemon-reload
|
||||||
for service in $SERVICES; do
|
for service in $SERVICES; do
|
||||||
systemctl enable ${service}.service
|
systemctl enable ${service}.service
|
||||||
done
|
done
|
||||||
|
|
|
@ -22,11 +22,5 @@ end script
|
||||||
|
|
||||||
exec start-stop-daemon \
|
exec start-stop-daemon \
|
||||||
--start -c $USER -d $VENV/pandora --exec \
|
--start -c $USER -d $VENV/pandora --exec \
|
||||||
$VENV/bin/gunicorn -- \
|
$VENV/bin/gunicorn -- wsgi:application \
|
||||||
wsgi:application \
|
-c $VENV/pandora/gunicorn_config.py -p /var/run/pandora/pandora.pid
|
||||||
--bind 127.0.0.1:2620 \
|
|
||||||
--timeout 90 \
|
|
||||||
--max-requests 1000 \
|
|
||||||
-p /var/run/pandora/pandora.pid \
|
|
||||||
--log-level info --log-file /var/log/pandora/pandora.log \
|
|
||||||
--workers 5
|
|
||||||
|
|
|
@ -11,14 +11,7 @@ WorkingDirectory=/srv/pandora/pandora
|
||||||
StandardOutput=syslog
|
StandardOutput=syslog
|
||||||
StandardError=syslog
|
StandardError=syslog
|
||||||
ExecStartPre=/srv/pandora/pandora/manage.py compile_pyc -p /srv/pandora/pandora
|
ExecStartPre=/srv/pandora/pandora/manage.py compile_pyc -p /srv/pandora/pandora
|
||||||
ExecStart=/srv/pandora/bin/gunicorn \
|
ExecStart=/srv/pandora/bin/gunicorn wsgi:application -c gunicorn_config.py -p $MAINPID
|
||||||
wsgi:application \
|
|
||||||
-p /run/pandora/pandora.pid \
|
|
||||||
--bind 127.0.0.1:2620 \
|
|
||||||
--timeout 90 \
|
|
||||||
--max-requests 1000 \
|
|
||||||
--log-level info \
|
|
||||||
--workers 5
|
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|
5
pandora/gunicorn_config.py.in
Normal file
5
pandora/gunicorn_config.py.in
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
bind="127.0.0.1:2620"
|
||||||
|
log_level="info"
|
||||||
|
max_requests=1000
|
||||||
|
timeout=90
|
||||||
|
workers=5
|
17
update.py
17
update.py
|
@ -197,6 +197,23 @@ if __name__ == "__main__":
|
||||||
path = os.path.join(pandora.settings.GEOIP_PATH, 'GeoLite2-City.mmdb')
|
path = os.path.join(pandora.settings.GEOIP_PATH, 'GeoLite2-City.mmdb')
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
run('./pandora/manage.py', 'update_geoip')
|
run('./pandora/manage.py', 'update_geoip')
|
||||||
|
if old <= 5443:
|
||||||
|
gunicorn_config = 'pandora/gunicorn_config.py'
|
||||||
|
if not os.path.exists(gunicorn_config):
|
||||||
|
shutil.copy('%s.in'%gunicorn_config, gunicorn_config)
|
||||||
|
if os.path.exists('/etc/init/pandora.conf'):
|
||||||
|
with open('/etc/init/pandora.conf') as fd:
|
||||||
|
data = fd.read()
|
||||||
|
if '0.0.0.0:2620' in data:
|
||||||
|
run('sed', '-i', 's/127.0.0.1:2620/0.0.0.0:2620/g', gunicorn_config)
|
||||||
|
if old > 5389:
|
||||||
|
service = 'pandora'
|
||||||
|
print('Please install new init script for "%s" service:' % service)
|
||||||
|
if os.path.exists('/etc/init'):
|
||||||
|
print('\tsudo cp %s/etc/init/%s.conf /etc/init/' % (base, service))
|
||||||
|
if os.path.exists('/lib/systemd/system'):
|
||||||
|
print('\tsudo cp %s/etc/systemd/%s.service /lib/systemd/system/' % (base, service))
|
||||||
|
print('\tsudo service %s restart' % service)
|
||||||
else:
|
else:
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
release = get_release()
|
release = get_release()
|
||||||
|
|
Loading…
Reference in a new issue