Gentoo Archives: gentoo-commits

From: "Alexys Jacob (ultrabug)" <ultrabug@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in www-servers/uwsgi/files: uwsgi.initd-r6
Date: Wed, 01 Jul 2015 10:30:28
Message-Id: 20150701103021.8B8FC74D@oystercatcher.gentoo.org
1 ultrabug 15/07/01 10:30:21
2
3 Added: uwsgi.initd-r6
4 Log:
5 fix init script /run perms to allow emperor group sockets to be created
6
7 (Portage version: 2.2.20/cvs/Linux x86_64, signed Manifest commit with key B658FA13)
8
9 Revision Changes Path
10 1.1 www-servers/uwsgi/files/uwsgi.initd-r6
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-servers/uwsgi/files/uwsgi.initd-r6?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-servers/uwsgi/files/uwsgi.initd-r6?rev=1.1&content-type=text/plain
14
15 Index: uwsgi.initd-r6
16 ===================================================================
17 #!/sbin/runscript
18 # Copyright 1999-2015 Gentoo Foundation
19 # Distributed under the terms of the GNU General Public License v2
20 # $Header: /var/cvsroot/gentoo-x86/www-servers/uwsgi/files/uwsgi.initd-r6,v 1.1 2015/07/01 10:30:21 ultrabug Exp $
21
22 PROGNAME=${SVCNAME#*.}
23
24 UWSGI_EXEC=/usr/bin/uwsgi
25 if [ "${SVCNAME}" = "uwsgi" ]; then
26 PIDPATH=/var/run/uwsgi
27 else
28 PIDPATH="/var/run/uwsgi_${PROGNAME}"
29 fi
30 PIDFILE="${PIDPATH}/${PROGNAME}.pid"
31
32 extra_started_commands="${opts} reload stats"
33
34 depend() {
35 need net
36 }
37
38 start_emperor() {
39 local OPTIONS
40 OPTIONS="--daemonize"
41
42 if [ -n "${UWSGI_LOG_FILE}" ]; then
43 OPTIONS="${OPTIONS} ${UWSGI_LOG_FILE}"
44 else
45 OPTIONS="${OPTIONS} /dev/null --disable-logging"
46 fi
47
48 [ -z "${UWSGI_DIR}" ] && UWSGI_DIR="/"
49 [ -z "${UWSGI_USER}" ] && UWSGI_USER="root"
50 [ -z "${UWSGI_GROUP}" ] && UWSGI_GROUP="root"
51
52 if [ -n "${UWSGI_EXTRA_OPTIONS}" ]; then
53 OPTIONS="${OPTIONS} ${UWSGI_EXTRA_OPTIONS}"
54 fi
55
56 ebegin "Starting uWSGI emperor"
57 checkpath -d -m 0770 -o "${UWSGI_USER}":"${UWSGI_EMPEROR_GROUP:-${UWSGI_GROUP}}" "${PIDPATH}"
58
59 cd "${UWSGI_DIR}" && \
60 start-stop-daemon --start --user "${UWSGI_USER}" --exec "${UWSGI_EXEC}" \
61 --group ${UWSGI_EMPEROR_GROUP:-${UWSGI_GROUP}} \
62 -- --emperor "${UWSGI_EMPEROR_PATH}" ${OPTIONS} --pidfile "${PIDFILE}"
63 return $?
64 }
65
66 start_app() {
67 local OPTIONS
68 OPTIONS="--master --daemonize"
69
70 if [ -n "${UWSGI_LOG_FILE}" ]; then
71 OPTIONS="${OPTIONS} ${UWSGI_LOG_FILE}"
72 else
73 OPTIONS="${OPTIONS} /dev/null --disable-logging"
74 fi
75
76 [ -z "${UWSGI_DIR}" ] && UWSGI_DIR="/"
77 [ -z "${UWSGI_USER}" ] && UWSGI_USER="root"
78 [ -z "${UWSGI_GROUP}" ] && UWSGI_GROUP="root"
79
80 if [ -n "${UWSGI_EXTRA_OPTIONS}" ]; then
81 OPTIONS="${OPTIONS} ${UWSGI_EXTRA_OPTIONS}"
82 fi
83
84 if [ "${UWSGI_THREADS}" = "1" ]; then
85 OPTIONS="${OPTIONS} --enable-threads"
86 fi
87
88 if [ -n "${UWSGI_SOCKET}" ]; then
89 OPTIONS="${OPTIONS} --socket ${UWSGI_SOCKET}"
90 fi
91
92 if [ -n "${UWSGI_PROCESSES}" ]; then
93 OPTIONS="${OPTIONS} --processes ${UWSGI_PROCESSES}"
94 fi
95
96 if [ -n "${UWSGI_CHROOT}" ]; then
97 OPTIONS="${OPTIONS} --chroot ${UWSGI_CHROOT}"
98 fi
99
100 if [ -n "${UWSGI_PROGRAM}" ]; then
101 OPTIONS="${OPTIONS} --fileserve-mode ${UWSGI_PROGRAM}"
102 fi
103
104 if [ -n "${UWSGI_XML_CONFIG}" ]; then
105 OPTIONS="${OPTIONS} --xmlconfig ${UWSGI_XML_CONFIG}"
106 fi
107
108 ebegin "Starting uWSGI application ${PROGNAME}"
109 checkpath -d -m 0750 -o "${UWSGI_USER}":"${UWSGI_GROUP}" "${PIDPATH}"
110
111 cd "${UWSGI_DIR}" && \
112 start-stop-daemon --start --user "${UWSGI_USER}" --group "${UWSGI_GROUP}" \
113 --exec "${UWSGI_EXEC}" -- ${OPTIONS} --pidfile "${PIDFILE}"
114 return $?
115 }
116
117 start() {
118 if [ -n "${UWSGI_EMPEROR_PATH}" ]; then
119 start_emperor
120 eend $?
121 else
122 if [ "${SVCNAME}" = "uwsgi" ]; then
123 eerror "You are not supposed to run this script directly unless you"
124 eerror "want to run in Emperor mode. In that case please set the UWSGI_EMPEROR_PATH."
125 eerror "Otherwise create a symlink for the uwsgi application you want to run as well as"
126 eerror "a copy of the configuration file and modify it appropriately like so..."
127 eerror
128 eerror " ln -s uwsgi /etc/init.d/uwsgi.trac"
129 eerror " cp /etc/conf.d/uwsgi /etc/conf.d/uwsgi.trac"
130 eerror " nano /etc/conf.d/uwsgi.trac"
131 eerror
132 return 1
133 else
134 start_app
135 eend $?
136 fi
137 fi
138 }
139
140 stop() {
141 if [ -n "${UWSGI_EMPEROR_PATH}" ]; then
142 ebegin "Stopping uWSGI emperor"
143 else
144 ebegin "Stopping uWSGI application ${PROGNAME}"
145 fi
146 start-stop-daemon --stop --signal QUIT --pidfile "${PIDFILE}"
147 eend $?
148 }
149
150 reload() {
151 ebegin "Reloading uWSGI"
152 start-stop-daemon --signal HUP --pidfile "${PIDFILE}"
153 eend $?
154 }
155
156 stats() {
157 ebegin "Logging uWSGI statistics"
158 start-stop-daemon --signal USR1 --pidfile "${PIDFILE}"
159 eend $?
160 }