diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-02-02 20:25:14 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-02-03 15:27:59 +0200 |
commit | 39217d34cbe9be990f2f2687f46037f556f8de73 (patch) | |
tree | 68088621513143b9e9af6f32f30b5c31f39327d3 | |
parent | 207d82bb24f83df0fe71c73f700cec076ffdcfc5 (diff) | |
download | qvisqve-39217d34cbe9be990f2f2687f46037f556f8de73.tar.gz |
Change: start_salami port, pid-file and daemonisation
start_salami now gets the port number for the Bottle variant from the
config file, instead of hardcoding it as 12765. Additionally, the pid
file is not optional for gunicorn use (it's not wanted when Salami is
started by systemd). Additionally, gunicorn is no longer
daemonised (also unwnted in the systemd case).
-rwxr-xr-x | start_salami | 49 | ||||
-rw-r--r-- | yarns/lib.py | 2 |
2 files changed, 25 insertions, 26 deletions
diff --git a/start_salami b/start_salami index 16a09f5..83a5a60 100755 --- a/start_salami +++ b/start_salami @@ -30,23 +30,12 @@ print(config.get(varname, "")) } -gunicorn_wanted() -{ - set -eu - case "$(get "$1" gunicorn)" in - yes|True) - return 0 - ;; - esac - return 1 -} - - run_bottle() { set -eu + local port="$(get "$config" gunicorn-port)" export SALAMI_CONFIG="$1" - python3 -c 'import salami; salami.create_app().run(host="127.0.0.1", port=12765)' + python3 -c "import salami; salami.create_app().run(host='127.0.0.1', port=$port)" } @@ -55,6 +44,7 @@ run_gunicorn() { set -eu local config="$1" + local gunicorn="$(get "$config" gunicorn)" local log_file="$(get "$config" gunicorn-log)" local pid_file="$(get "$config" gunicorn-pid-file)" local port="$(get "$config" gunicorn-port)" @@ -66,22 +56,31 @@ run_gunicorn() pid_opt="-p $pid_file" fi - export SALAMI_CONFIG="$config" - gunicorn3 \ - --bind 127.0.0.1:"$port" \ + opts=" + --bind 127.0.0.1:$port \ -w1 \ - --log-file "$log_file" \ - "$pid_opt" \ + --log-file $log_file \ + $pid_opt \ --log-level debug \ - --daemon \ - salami.backend:app + " + + if [ "$gunicorn" = background ] + then + opts="$opts --daemon" + fi + + export SALAMI_CONFIG="$config" + gunicorn3 $opts salami.backend:app } config="$1" -if gunicorn_wanted "$config" -then - run_gunicorn "$config" -else +gunicorn="$(get "$config" gunicorn)" +case "$gunicorn" in + no) run_bottle "$config" -fi + ;; + yes|True|background) + run_gunicorn "$config" + ;; +esac diff --git a/yarns/lib.py b/yarns/lib.py index b36869d..8379b16 100644 --- a/yarns/lib.py +++ b/yarns/lib.py @@ -185,7 +185,7 @@ def start_salami(): } config = { - 'gunicorn': True, + 'gunicorn': 'background', 'gunicorn-log': 'gunicorn.log', 'gunicorn-pid-file': V['pid-file'], 'gunicorn-port': V['port'], |