Projet

Général

Profil

0001-debian-switch-to-uwsgi-41204.patch

Frédéric Péters, 31 mars 2020 20:40

Télécharger (6,01 ko)

Voir les différences:

Subject: [PATCH] debian: switch to uwsgi (#41204)

 debian/control       |  3 ++-
 debian/uwsgi.ini     | 26 ++++++++++++++++++++++++
 debian/welco.init    | 47 ++++++++++----------------------------------
 debian/welco.install |  1 +
 debian/welco.service | 15 +++++++-------
 5 files changed, 46 insertions(+), 46 deletions(-)
 create mode 100644 debian/uwsgi.ini
debian/control
28 28
    python-psycopg2,
29 29
    python-django-mellon,
30 30
    python-xstatic-select2,
31
    gunicorn,
31
    uwsgi,
32
    uwsgi-plugin-python,
32 33
    graphicsmagick
33 34
Recommends: nginx
34 35
Suggests: postgresql
debian/uwsgi.ini
1
[uwsgi]
2
auto-procname = true
3
procname-prefix-spaced = welco
4

  
5
plugin = python
6
module = welco.wsgi:application
7

  
8
http-socket = /run/welco/welco.sock
9
chmod-socket = 666
10
vacuum = true
11

  
12
master = true
13
processes = 5
14
harakiri = 120
15
enable-threads = true
16

  
17
buffer-size = 32768
18

  
19
py-tracebacker = /run/welco/py-tracebacker.sock.
20
stats = /run/welco/stats.sock
21

  
22
ignore-sigpipe = true
23

  
24
if-file = /etc/welco/uwsgi-local.ini
25
  include = /etc/welco/uwsgi-local.ini
26
endif =
debian/welco.init
16 16
PATH=/sbin:/usr/sbin:/bin:/usr/bin
17 17
DESC="Multichannel request processing"
18 18
NAME=welco
19
DAEMON=/usr/bin/gunicorn
19
DAEMON=/usr/bin/uwsgi
20 20
RUN_DIR=/run/$NAME
21 21
PIDFILE=$RUN_DIR/$NAME.pid
22 22
LOG_DIR=/var/log/$NAME
23 23
SCRIPTNAME=/etc/init.d/$NAME
24 24
BIND=unix:$RUN_DIR/$NAME.sock
25
WORKERS=5
26
TIMEOUT=30
27 25

  
28 26
WELCO_SETTINGS_FILE=/usr/lib/$NAME/debian_config.py
29 27
MANAGE_SCRIPT="/usr/bin/$NAME-manage"
......
37 35
# Read configuration variable file if it is present
38 36
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
39 37

  
40
DAEMON_ARGS=${DAEMON_ARGS:-"--pid $PIDFILE \
41
--user $USER --group $GROUP \
42
--daemon \
43
--access-logfile $LOG_DIR/gunicorn-access.log \
44
--log-file $LOG_DIR/gunicorn-error.log \
45
--bind=$BIND  \
46
--workers=$WORKERS \
47
--worker-class=sync \
48
--timeout=$TIMEOUT \
49
--name $NAME \
50
$NAME.wsgi:application"}
38
DAEMON_ARGS=${DAEMON_ARGS:-"--pidfile=$PIDFILE
39
--uid $USER --gid $GROUP
40
--ini /etc/$NAME/uwsgi.ini
41
--daemonize /var/log/uwsgi.$NAME.log"}
51 42

  
52 43
# Load the VERBOSE setting and other rcS variables
53 44
. /lib/init/vars.sh
......
73 64
    #   0 if daemon has been started
74 65
    #   1 if daemon was already running
75 66
    #   2 if daemon could not be started
76
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
77
        || return 1
78
    start-stop-daemon --start --quiet --exec $DAEMON -- \
67
    start-stop-daemon --start --quiet --user $USER --exec $DAEMON -- \
79 68
        $DAEMON_ARGS \
80 69
        || return 2
81 70
}
......
90 79
    #   1 if daemon was already stopped
91 80
    #   2 if daemon could not be stopped
92 81
    #   other if a failure occurred
93
    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
94
    RETVAL="$?"
95
    [ "$RETVAL" = 2 ] && return 2
96
    # Wait for children to finish too if this is a daemon that forks
97
    # and if the daemon is only ever run from this initscript.
98
    # If the above conditions are not satisfied then add some other code
99
    # that waits for the process to drop all resources that could be
100
    # needed by services started subsequently.  A last resort is to
101
    # sleep for some time.
102
    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
103
    [ "$?" = 2 ] && return 2
104
    # Many daemons don't delete their pidfiles when they exit.
82
    $DAEMON --stop $PIDFILE
105 83
    rm -f $PIDFILE
106
    return "$RETVAL"
84
    return 0 # hopefully
107 85
}
108 86

  
109 87
#
110 88
# Function that sends a SIGHUP to the daemon/service
111 89
#
112 90
do_reload() {
113
    #
114
    # If the daemon can reload its configuration without
115
    # restarting (for example, when it is sent a SIGHUP),
116
    # then implement that here.
117
    #
118
    start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name `basename $DAEMON`
91
    $DAEMON --reload $PIDFILE
119 92
    return 0
120 93
}
121 94

  
......
151 124
    esac
152 125
    ;;
153 126
  status)
154
    status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
127
    status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $?
155 128
    ;;
156 129
  reload|force-reload)
157 130
    #
debian/welco.install
1 1
debian/welco-manage       /usr/bin
2 2
debian/settings.py        /etc/welco
3
debian/uwsgi.ini          /etc/welco
3 4
debian/debian_config.py   /usr/lib/welco
4 5
debian/welco.service      /lib/systemd/system
debian/welco.service
1 1
[Unit]
2 2
Description=Welco
3
After=network.target postgresql.service
3
After=network.target syslog.target postgresql.service
4 4
Wants=postgresql.service
5 5

  
6 6
[Service]
7 7
Environment=WELCO_SETTINGS_FILE=/usr/lib/%p/debian_config.py
8
Environment=LANG=C.UTF-8
8 9
User=%p
9 10
Group=%p
10 11
ExecStartPre=/usr/bin/welco-manage migrate_schemas --noinput --verbosity 1
11 12
ExecStartPre=/usr/bin/welco-manage collectstatic --noinput
12
ExecStart=/usr/bin/gunicorn \
13
          --bind unix:/run/%p/%p.sock \
14
          --worker-class=sync \
15
          --workers 5 \
16
          --timeout=30 \
17
          --name %p \
18
          %p.wsgi:application
13
ExecStart=/usr/bin/uwsgi --ini /etc/%p/uwsgi.ini
19 14
ExecReload=/bin/kill -HUP $MAINPID
15
KillSignal=SIGQUIT
20 16
TimeoutStartSec=0
21 17
PrivateTmp=true
22 18
Restart=on-failure
23 19
RuntimeDirectory=welco
20
Type=notify
21
StandardError=syslog
22
NotifyAccess=all
24 23

  
25 24
[Install]
26 25
WantedBy=multi-user.target
27
-