Add systemd service file, move Gunicorn config to gunicorn.cfg
This commit is contained in:
parent
1d2387683a
commit
883cb9ee7c
3 changed files with 26 additions and 6 deletions
5
gunicorn.cfg
Normal file
5
gunicorn.cfg
Normal 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
20
oebbapi.service
Normal 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
7
run.sh
|
@ -1,8 +1,3 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ip="0.0.0.0"
|
gunicorn -c gunicorn.cfg main
|
||||||
port="8803"
|
|
||||||
|
|
||||||
workers=$((`getconf _NPROCESSORS_ONLN` * 4))
|
|
||||||
|
|
||||||
gunicorn -w $workers -b $ip:$port -n "OEBB API" main
|
|
||||||
|
|
Loading…
Reference in a new issue