Add systemd service file, move Gunicorn config to gunicorn.cfg

This commit is contained in:
Klaus-Uwe Mitterer 2017-10-18 12:44:24 +02:00
parent 1d2387683a
commit 883cb9ee7c
3 changed files with 26 additions and 6 deletions

5
gunicorn.cfg Normal file
View file

@ -0,0 +1,5 @@
import multiprocessing
name = "OEBBAPI"
bind = "0.0.0.0:8803"
workers = multiprocessing.cpu_count() * 4

20
oebbapi.service Normal file
View file

@ -0,0 +1,20 @@
[Unit]
Description = OEBBAPI
After = network.target
[Service]
PermissionsStartOnly = true
PIDFile = /run/oebbapi/oebbapi.pid
User = oebb
Group = oebb
WorkingDirectory = /opt/oebbapi
ExecStartPre = /bin/mkdir /run/oebbapi
ExecStartPre = /bin/chown -R oebb:oebb /run/oebbapi
ExecStart = /usr/bin/env gunicorn -c gunicorn.cfg --pid /run/oebbapi/oebbapi.pid main
ExecReload = /bin/kill -s HUP $MAINPID
ExecStop = /bin/kill -s TERM $MAINPID
ExecStopPost = /bin/rm -rf /run/oebbapi
PrivateTmp = true
[Install]
WantedBy = multi-user.target

7
run.sh
View file

@ -1,8 +1,3 @@
#!/bin/bash
ip="0.0.0.0"
port="8803"
workers=$((`getconf _NPROCESSORS_ONLN` * 4))
gunicorn -w $workers -b $ip:$port -n "OEBB API" main
gunicorn -c gunicorn.cfg main