1 |
ultrabug 13/03/01 09:50:07 |
2 |
|
3 |
Added: uwsgi.initd-r3 uwsgi.confd-r3 |
4 |
Log: |
5 |
Introduce UWSGI_GROUP and UWSGI_EMPEROR_GROUP conf.d variables |
6 |
|
7 |
(Portage version: 2.1.11.52/cvs/Linux x86_64, signed Manifest commit with key B658FA13) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 www-servers/uwsgi/files/uwsgi.initd-r3 |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-servers/uwsgi/files/uwsgi.initd-r3?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-servers/uwsgi/files/uwsgi.initd-r3?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: uwsgi.initd-r3 |
16 |
=================================================================== |
17 |
#!/sbin/runscript |
18 |
# Copyright 1999-2013 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-r3,v 1.1 2013/03/01 09:50:06 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_pre() { |
39 |
checkpath -d -m 0750 -o "${UWSGI_USER}":"${UWSGI_GROUP}" "${PIDPATH}" |
40 |
} |
41 |
|
42 |
start_emperor() { |
43 |
local OPTIONS |
44 |
OPTIONS="--daemonize" |
45 |
|
46 |
if [ -n "${UWSGI_LOG_FILE}" ]; then |
47 |
OPTIONS="${OPTIONS} ${UWSGI_LOG_FILE}" |
48 |
else |
49 |
OPTIONS="${OPTIONS} /dev/null --disable-logging" |
50 |
fi |
51 |
|
52 |
[ -z "${UWSGI_DIR}" ] && UWSGI_DIR="/" |
53 |
[ -z "${UWSGI_USER}" ] && UWSGI_USER="root" |
54 |
[ -z "${UWSGI_GROUP}" ] && UWSGI_GROUP="root" |
55 |
|
56 |
if [ -n "${UWSGI_EXTRA_OPTIONS}" ]; then |
57 |
OPTIONS="${OPTIONS} ${UWSGI_EXTRA_OPTIONS}" |
58 |
fi |
59 |
|
60 |
ebegin "Starting uWSGI emperor" |
61 |
cd "${UWSGI_DIR}" && \ |
62 |
start-stop-daemon --start --user "${UWSGI_USER}" --exec "${UWSGI_EXEC}" \ |
63 |
--group ${UWSGI_EMPEROR_GROUP:-${UWSGI_GROUP}} \ |
64 |
-- --emperor "${UWSGI_EMPEROR_PATH}" ${OPTIONS} --pidfile "${PIDFILE}" |
65 |
return $? |
66 |
} |
67 |
|
68 |
start_app() { |
69 |
local OPTIONS |
70 |
OPTIONS="--master --daemonize" |
71 |
|
72 |
if [ -n "${UWSGI_LOG_FILE}" ]; then |
73 |
OPTIONS="${OPTIONS} ${UWSGI_LOG_FILE}" |
74 |
else |
75 |
OPTIONS="${OPTIONS} /dev/null --disable-logging" |
76 |
fi |
77 |
|
78 |
[ -z "${UWSGI_DIR}" ] && UWSGI_DIR="/" |
79 |
[ -z "${UWSGI_USER}" ] && UWSGI_USER="root" |
80 |
[ -z "${UWSGI_GROUP}" ] && UWSGI_GROUP="root" |
81 |
|
82 |
if [ -n "${UWSGI_EXTRA_OPTIONS}" ]; then |
83 |
OPTIONS="${OPTIONS} ${UWSGI_EXTRA_OPTIONS}" |
84 |
fi |
85 |
|
86 |
if [ "${UWSGI_THREADS}" = "1" ]; then |
87 |
OPTIONS="${OPTIONS} --enable-threads" |
88 |
fi |
89 |
|
90 |
if [ -n "${UWSGI_SOCKET}" ]; then |
91 |
OPTIONS="${OPTIONS} --socket ${UWSGI_SOCKET}" |
92 |
fi |
93 |
|
94 |
if [ -n "${UWSGI_PROCESSES}" ]; then |
95 |
OPTIONS="${OPTIONS} --processes ${UWSGI_PROCESSES}" |
96 |
fi |
97 |
|
98 |
if [ -n "${UWSGI_CHROOT}" ]; then |
99 |
OPTIONS="${OPTIONS} --chroot ${UWSGI_CHROOT}" |
100 |
fi |
101 |
|
102 |
if [ -n "${UWSGI_PROGRAM}" ]; then |
103 |
OPTIONS="${OPTIONS} --fileserve-mode ${UWSGI_PROGRAM}" |
104 |
fi |
105 |
|
106 |
if [ -n "${UWSGI_XML_CONFIG}" ]; then |
107 |
OPTIONS="${OPTIONS} --xmlconfig ${UWSGI_XML_CONFIG}" |
108 |
fi |
109 |
|
110 |
ebegin "Starting uWSGI application ${PROGNAME}" |
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 [ "${SVCNAME}" == "uwsgi" ]; then |
119 |
if [ -n "${UWSGI_EMPEROR_PATH}" ]; then |
120 |
start_emperor |
121 |
eend $? |
122 |
else |
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 |
fi |
134 |
else |
135 |
start_app |
136 |
eend $? |
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 |
} |
161 |
|
162 |
|
163 |
|
164 |
1.1 www-servers/uwsgi/files/uwsgi.confd-r3 |
165 |
|
166 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-servers/uwsgi/files/uwsgi.confd-r3?rev=1.1&view=markup |
167 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/www-servers/uwsgi/files/uwsgi.confd-r3?rev=1.1&content-type=text/plain |
168 |
|
169 |
Index: uwsgi.confd-r3 |
170 |
=================================================================== |
171 |
# Distributed under the terms of the GNU General Public License v2 |
172 |
# $Header: /var/cvsroot/gentoo-x86/www-servers/uwsgi/files/uwsgi.confd-r3,v 1.1 2013/03/01 09:50:06 ultrabug Exp $ |
173 |
|
174 |
# YOU SHOULD ONLY MODIFY THIS FILE IF YOU USE THE UWSGI EMPEROR MODE! |
175 |
# IF YOU WANT TO RUN A SINGLE APP INSTANCE, CREATE A COPY AND MODIFY THAT INSTEAD! |
176 |
|
177 |
# Path (or name) of UNIX/TCP socket to bind to |
178 |
# Example : UWSGI_SOCKET=127.0.0.1:1234 |
179 |
UWSGI_SOCKET= |
180 |
|
181 |
# Enable threads? (1 = yes, 0 = no). The default is 0 |
182 |
# |
183 |
UWSGI_THREADS=0 |
184 |
|
185 |
# The path to your uWSGI application. |
186 |
# |
187 |
UWSGI_PROGRAM= |
188 |
|
189 |
# The path to your uWSGI xml config file. |
190 |
# |
191 |
UWSGI_XML_CONFIG= |
192 |
|
193 |
# The number of child processes to spawn. The default is 1. |
194 |
# |
195 |
UWSGI_PROCESSES=1 |
196 |
|
197 |
# The log file path. If empty, log only errors |
198 |
# |
199 |
UWSGI_LOG_FILE= |
200 |
|
201 |
# If you want to run your application inside a chroot then specify the |
202 |
# directory here. Leave this blank otherwise. |
203 |
# |
204 |
UWSGI_CHROOT= |
205 |
|
206 |
# If you want to run your application from a specific directiory specify |
207 |
# it here. Leave this blank otherwise. |
208 |
# |
209 |
UWSGI_DIR= |
210 |
|
211 |
# The user to run your application as. If you do not specify these, |
212 |
# the application will be run as user root. |
213 |
# |
214 |
UWSGI_USER= |
215 |
|
216 |
# The group to run your application as. If you do not specify these, |
217 |
# the application will be run as group root. |
218 |
# |
219 |
UWSGI_GROUP= |
220 |
|
221 |
# Run the uwsgi emperor which loads vassals dynamically from this PATH |
222 |
# see http://projects.unbit.it/uwsgi/wiki/Emperor |
223 |
# The advised Gentoo folder is /etc/uwsgi.d/ |
224 |
UWSGI_EMPEROR_PATH= |
225 |
|
226 |
# The group the emperor should run as. This is different from the UWSGI_GROUP |
227 |
# as you could want your apps share some sockets with other processes such as |
228 |
# www servers while preserving your emperor logs from being accessible by them. |
229 |
UWSGI_EMPEROR_GROUP= |
230 |
|
231 |
# Additional options you might want to pass to uWSGI |
232 |
# |
233 |
UWSGI_EXTRA_OPTIONS= |