-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrun_server
executable file
·51 lines (43 loc) · 1.7 KB
/
run_server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Copyright (C) 2016 Michel Müller
# This file is part of Guetzli.
# Guetzli is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Guetzli is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License
# along with Guetzli. If not, see <http://www.gnu.org/licenses/>.
# ============ preamble ================== #
set -o errexit #exit when command fails
set -o nounset #exit when trying to use undeclared variable
set -o pipefail #pass along errors within a pipe
# =============== setup ================== #
working_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
log_file="${working_dir}/guetzli_log"
pid_file="${working_dir}/uwsgi.pid"
port=5000
site=""
if [[ $# > 0 ]] ; then
site="$1"
fi
autopull_key=""
if [[ $# > 1 ]] ; then
autopull_key="$2"
fi
autopull_branch=""
if [[ $# > 2 ]] ; then
autopull_branch="$3"
fi
autopull_untrusted=""
if [[ $# > 3 ]] ; then
autopull_untrusted="$4"
fi
# ========= eat the guetzli ============== #
touch "$log_file"
uwsgi --stop "$pid_file" && :
sleep 1
uwsgi --master --processes 4 --offload-threads 4 --http :$port --daemonize "$log_file" --pidfile "$pid_file" -w server:app --static-map /static="$working_dir/design/static" --pyargv "$site $autopull_key $autopull_branch $autopull_untrusted" --buffer-size 65536 --socket-timeout 5 --listen 5