]>
Commit | Line | Data |
---|---|---|
635d4df2 | 1 | |
8c88d03f JK |
2 | %bcond_without xml |
3 | %bcond_without yaml | |
4 | %bcond_without zeromq | |
5 | %bcond_without ssl | |
6 | %bcond_without pcre | |
7 | %bcond_without routing | |
8 | %bcond_without matheval | |
b698a6be JK |
9 | %bcond_without python2 |
10 | %bcond_without python3 | |
8c88d03f JK |
11 | %bcond_with json |
12 | ||
fb7b42d0 | 13 | # TODO: |
7b5bd0fa | 14 | # - pl desc |
134b53b7 | 15 | # - apache, module? |
59ca712c JK |
16 | # - 'gevent' plugin depends on python and works only after python plugin is loaded |
17 | # this can probably be fixed by better linking | |
18 | ||
4dbfa3ab | 19 | Summary: Fast WSGI server |
20 | Summary(pl.UTF-8): Szybki serwer WSGI | |
21 | Name: uwsgi | |
3c58037d | 22 | Version: 2.0.10 |
fd3962bc | 23 | Release: 1 |
4dbfa3ab | 24 | License: GPL v2 |
25 | Group: Networking/Daemons | |
26 | Source0: http://projects.unbit.it/downloads/%{name}-%{version}.tar.gz | |
3c58037d | 27 | # Source0-md5: 7a9be0db5f6a8d4150dc5e9e0517ce80 |
7b5bd0fa | 28 | Source1: %{name}.init |
0eec4912 JK |
29 | Source2: emperor.ini |
30 | Source3: %{name}.tmpfiles | |
a2e939cb | 31 | Source4: %{name}.service |
b698a6be | 32 | Patch0: %{name}-plugin_build_dir.patch |
4dbfa3ab | 33 | URL: http://projects.unbit.it/uwsgi/ |
8c88d03f JK |
34 | %{?with_xml:BuildRequires: libxml2-devel} |
35 | %{?with_yaml:BuildRequires: yaml-devel} | |
36 | %{?with_json:BuildRequires: jansson-devel} | |
37 | %{?with_zeromq:BuildRequires: zeromq-devel} | |
38 | %{?with_ssl:BuildRequires: openssl-devel} | |
39 | %{?with_matheval:BuildRequires: libmatheval-devel} | |
40 | %{!?with_matheval:BuildConflicts: libmatheval-devel} | |
41 | %if %{with pcre} || %{with routing} | |
42 | BuildRequires: pcre-devel | |
43 | %endif | |
44 | BuildRequires: libcap-devel | |
45 | BuildRequires: libuuid-devel | |
46 | BuildRequires: zlib-devel | |
635d4df2 | 47 | BuildRequires: python-modules |
b698a6be JK |
48 | %if %{with python2} |
49 | BuildRequires: python-devel >= 1:2.7 | |
50 | %endif | |
51 | %if %{with python3} | |
52 | BuildRequires: python3-devel >= 1:2.7 | |
53 | BuildRequires: python3-modules | |
54 | %endif | |
a2e939cb JK |
55 | Requires(post,preun): /sbin/chkconfig |
56 | Requires(postun): /usr/sbin/groupdel | |
57 | Requires(postun): /usr/sbin/userdel | |
58 | Requires(pre): /bin/id | |
59 | Requires(pre): /usr/bin/getgid | |
60 | Requires(pre): /usr/sbin/groupadd | |
61 | Requires(pre): /usr/sbin/useradd | |
62 | Requires: rc-scripts >= 0.4.3.0 | |
63 | Requires: systemd-units >= 38 | |
0eec4912 | 64 | Suggests: uwsgi-plugin-python |
4dbfa3ab | 65 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
66 | ||
b698a6be JK |
67 | %define pyver %(echo %{py_ver} | tr -d .) |
68 | %define py3ver %(echo %{py3_ver} | tr -d .) | |
69 | ||
380ddf7d JK |
70 | %define _noautoprovfiles %{_libdir}/%{name}/.* |
71 | ||
4dbfa3ab | 72 | %description |
73 | uWSGI is a fast (pure C), self-healing, developer-friendly WSGI | |
74 | server, aimed for professional python webapps deployment and | |
75 | development. Over time it has evolved in a complete stack for | |
76 | networked/clustered python applications, implementing message/object | |
77 | passing and process management. It uses the uwsgi (all lowercase) | |
78 | protocol for all the networking/interprocess communications. From the | |
79 | 0.9.5 release it includes a plugin loading technology that can be used | |
80 | to add support for other languages or platform. A Lua wsapi adaptor, a | |
81 | PSGI handler and an Erlang message exchanger are already available. | |
82 | ||
b698a6be JK |
83 | %package plugin-python |
84 | Summary: Python 2.x plugin for uWSGI | |
85 | Group: Networking/Daemons | |
86 | Requires: %{name} = %{version}-%{release} | |
87 | ||
88 | %description plugin-python | |
89 | Python 2.x plugin for uWSGI. | |
90 | ||
91 | %package plugin-python3 | |
92 | Summary: Python 3.x plugin for uWSGI | |
93 | Group: Networking/Daemons | |
94 | Requires: %{name} = %{version}-%{release} | |
95 | ||
96 | %description plugin-python3 | |
97 | Python 3.x plugin for uWSGI. | |
98 | ||
4dbfa3ab | 99 | %prep |
100 | %setup -q | |
101 | ||
b698a6be JK |
102 | %patch0 -p1 |
103 | ||
4dbfa3ab | 104 | %build |
8c88d03f JK |
105 | cat >buildconf/pld.ini <<EOF |
106 | [uwsgi] | |
b698a6be JK |
107 | main_plugin = |
108 | embedded_plugins = | |
8c88d03f | 109 | inherit = base |
b698a6be | 110 | plugin_dir = %{_libdir}/uwsgi |
8c88d03f JK |
111 | |
112 | xml = %{?with_xml:true}%{!?with_xml:false} | |
113 | yaml = %{?with_yaml:true}%{!?with_yaml:false} | |
114 | zeromq = %{?with_zeromq:true}%{!?with_zeromq:false} | |
115 | ssl = %{?with_ssl:true}%{!?with_ssl:false} | |
116 | pcre = %{?with_pcre:true}%{!?with_pcre:false} | |
117 | routing = %{?with_routing:true}%{!?with_routing:false} | |
118 | matheval = %{?with_matheval:true}%{!?with_matheval:false} | |
119 | json = %{?with_json:true}%{!?with_json:false} | |
120 | ||
121 | %{?with_xml:xml_implementation = libxml2} | |
122 | EOF | |
123 | ||
124 | %{__python} uwsgiconfig.py --build pld | |
4dbfa3ab | 125 | |
b698a6be JK |
126 | # base plugin list from buildconf/base.ini |
127 | for plugin in \ | |
128 | ping cache nagios rrdtool carbon rpc corerouter \ | |
129 | fastrouter http ugreen signal syslog rsyslog logsocket \ | |
130 | router_uwsgi router_redirect router_basicauth zergpool \ | |
131 | redislog mongodblog router_rewrite router_http logfile \ | |
132 | router_cache rawrouter router_static sslrouter spooler \ | |
133 | cheaper_busyness symcall transformation_tofile \ | |
134 | transformation_gzip transformation_chunked \ | |
135 | transformation_offload router_memcached router_redis \ | |
136 | router_hash ; do | |
137 | ||
138 | %{__python} uwsgiconfig.py --plugin plugins/${plugin} pld ${plugin} | |
139 | done | |
140 | ||
7565c7ee JK |
141 | # extra non-base plugins |
142 | for plugin in cgi ; do | |
143 | %{__python} uwsgiconfig.py --plugin plugins/${plugin} pld ${plugin} | |
144 | done | |
145 | ||
b698a6be JK |
146 | %if %{with python2} |
147 | %{__python} uwsgiconfig.py --plugin plugins/python pld python%{pyver} | |
59ca712c | 148 | %{__python} uwsgiconfig.py --plugin plugins/gevent pld gevent_py%{pyver} |
b698a6be JK |
149 | %endif |
150 | %if %{with python3} | |
151 | %{__python3} uwsgiconfig.py --plugin plugins/python pld python%{py3ver} | |
59ca712c | 152 | %{__python3} uwsgiconfig.py --plugin plugins/gevent pld gevent_py%{py3ver} |
b698a6be JK |
153 | %endif |
154 | ||
4dbfa3ab | 155 | %install |
156 | rm -rf $RPM_BUILD_ROOT | |
b698a6be JK |
157 | install -d $RPM_BUILD_ROOT{%{_bindir},%{_libdir}/%{name}} \ |
158 | $RPM_BUILD_ROOT{%{_sysconfdir}/rc.d/init.d,%{_sysconfdir}/sysconfig} \ | |
0eec4912 | 159 | $RPM_BUILD_ROOT{%{_sysconfdir}/uwsgi/vassals,/var/{run/uwsgi,log}} \ |
a2e939cb | 160 | $RPM_BUILD_ROOT{%{systemdtmpfilesdir},%{systemdunitdir}} |
b698a6be | 161 | |
7b5bd0fa | 162 | touch $RPM_BUILD_ROOT/var/log/%{name}.log |
5ac287b5 | 163 | install uwsgi $RPM_BUILD_ROOT%{_bindir} |
7b5bd0fa | 164 | install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/%{name} |
0eec4912 JK |
165 | install %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/uwsgi/emperor.ini |
166 | install %{SOURCE3} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/%{name}.conf | |
a2e939cb | 167 | install %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service |
4dbfa3ab | 168 | |
b698a6be JK |
169 | install *_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name} |
170 | ||
59ca712c | 171 | # the symlinks must be absolute – otherwise strange things happen in strace |
b698a6be | 172 | %if %{with python2} |
59ca712c JK |
173 | ln -s %{_libdir}/%{name}/python%{pyver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/python_plugin.so |
174 | ln -s %{_libdir}/%{name}/gevent_py%{pyver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/gevent_plugin.so | |
b698a6be JK |
175 | %endif |
176 | %if %{with python3} | |
59ca712c JK |
177 | ln -s %{_libdir}/%{name}/python%{py3ver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/python3_plugin.so |
178 | ln -s %{_libdir}/%{name}/gevent_py%{py3ver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/gevent_py3_plugin.so | |
b698a6be JK |
179 | %endif |
180 | ||
4dbfa3ab | 181 | %clean |
182 | rm -rf $RPM_BUILD_ROOT | |
183 | ||
7b5bd0fa ŁC |
184 | %pre |
185 | %groupadd -r -g 270 %{name} | |
186 | %useradd -r -u 270 -d /usr/share/empty -s /bin/false -c "uWSGI User" -g %{name} %{name} | |
187 | ||
188 | %post | |
189 | /sbin/chkconfig --add %{name} | |
190 | touch /var/log/%{name}.log | |
191 | chown uwsgi:uwsgi /var/log/%{name}.log | |
192 | chmod 644 /var/log/%{name}.log | |
193 | %service %{name} restart | |
a2e939cb | 194 | %systemd_post %{name}.service |
7b5bd0fa ŁC |
195 | |
196 | %preun | |
197 | if [ "$1" = "0" ];then | |
198 | %service %{name} stop | |
199 | /sbin/chkconfig --del %{name} | |
200 | fi | |
a2e939cb | 201 | %systemd_preun %{name}.service |
7b5bd0fa ŁC |
202 | |
203 | %postun | |
204 | if [ "$1" = "0" ]; then | |
205 | %userremove %{name} | |
206 | %groupremove %{name} | |
207 | fi | |
a2e939cb | 208 | %systemd_reload |
7b5bd0fa | 209 | |
0eec4912 JK |
210 | %triggerpostun -- %{name} < 1.9.12-1.1 |
211 | UWSGI_CONFIG_FORMAT="xml" | |
212 | [ -f /etc/sysconfig/uwsgi.rpmsave ] && . /etc/sysconfig/uwsgi.rpmsave || : | |
213 | if [ "$UWSGI_CONFIG_FORMAT" = "xml" ] ; then | |
214 | if [ -f /etc/uwsgi/uwsgi.xml.rpmsave ] ; then | |
215 | sed -e 's/<daemonize>.*<\/daemonize>//' \ | |
216 | -e 's/<uwsgi>/<uwsgi>\n<plugins>python,gevent,ping,cache,nagios,rrdtool,carbon,rpc,corerouter,fastrouter,http,ugreen,signal,syslog,rsyslog,logsocket,router_uwsgi,router_redirect,router_basicauth,zergpool,redislog,mongodblog,router_rewrite,router_http,logfile,router_cache,rawrouter<\/plugins>/' \ | |
217 | < /etc/uwsgi/uwsgi.xml.rpmsave \ | |
218 | > /etc/uwsgi/vassals/uwsgi.xml || : | |
219 | else | |
220 | cat >/etc/uwsgi/vassals/uwsgi.xml << 'EOF' | |
221 | <uwsgi> | |
222 | <plugins>python,gevent,ping,cache,nagios,rrdtool,carbon,rpc,corerouter,fastrouter,http,ugreen,signal,syslog,rsyslog,logsocket,router_uwsgi,router_redirect,router_basicauth,zergpool,redislog,mongodblog,router_rewrite,router_http,logfile,router_cache,rawrouter</plugins> | |
223 | <pidfile>/var/run/uwsgi/uwsgi.pid</pidfile> | |
224 | <uid>uwsgi</uid> | |
225 | <gid>uwsgi</gid> | |
226 | <socket>/var/run/uwsgi/uwsgi.sock</socket> | |
227 | </uwsgi> | |
228 | EOF | |
229 | fi | |
230 | elif [ "$UWSGI_CONFIG_FORMAT" = "ini" ] ; then | |
231 | if [ -f /etc/uwsgi/uwsgi.ini.rpmsave ] ; then | |
232 | mv /etc/uwsgi/vassals/uwsgi.ini{,.rpmorig} | |
233 | sed -e 's/[ \t]*daemonize.*//' \ | |
234 | -e 's/^\[uwsgi\]/[uwsgi]\nplugins=python,gevent,ping,cache,nagios,rrdtool,carbon,rpc,corerouter,fastrouter,http,ugreen,signal,syslog,rsyslog,logsocket,router_uwsgi,router_redirect,router_basicauth,zergpool,redislog,mongodblog,router_rewrite,router_http,logfile,router_cache,rawrouter/' \ | |
235 | < /etc/uwsgi/uwsgi.ini.rpmsave \ | |
236 | > /etc/uwsgi/vassals/uwsgi.ini || : | |
237 | else | |
238 | cat >/etc/uwsgi/vassals/uwsgi.ini << 'EOF' | |
239 | [uwsgi] | |
240 | plugins = python,gevent,ping,cache,nagios,rrdtool,carbon,rpc,corerouter,fastrouter,http,ugreen,signal,syslog,rsyslog,logsocket,router_uwsgi,router_redirect,router_basicauth,zergpool,redislog,mongodblog,router_rewrite,router_http,logfile,router_cache,rawrouter | |
241 | socket = /var/run/uwsgi/uwsgi.sock | |
242 | uid = uwsgi | |
243 | gid = uwsgi | |
244 | pidfile = /var/run/uwsgi/uwsgi.pid | |
245 | EOF | |
246 | fi | |
247 | fi | |
248 | ||
249 | if [ -f /var/run/uwsgi/uwsgi.pid ] ; then | |
250 | # for the service restart to work | |
251 | mv /var/run/uwsgi/uwsgi.pid /var/run/uwsgi-emperor.pid || : | |
252 | fi | |
253 | ||
254 | %banner -e %{name} << 'EOF' | |
255 | uWSGI instance configuration has been moved to | |
256 | the %{_sysconfdir}/%{name}/vassals directory and | |
257 | updated to be started via uWSGI emperor with loadable plugins. | |
258 | ||
259 | The automatic configuration update might have failed, though. | |
260 | ||
261 | You should probably install uwsgi-plugin-python too. | |
262 | EOF | |
0eec4912 | 263 | %service %{name} restart |
a2e939cb | 264 | %systemd_trigger %{name}.service |
0eec4912 | 265 | |
4dbfa3ab | 266 | %files |
267 | %defattr(644,root,root,755) | |
44740c10 | 268 | %doc README |
bb5f8c47 | 269 | %attr(755,root,root) %{_bindir}/uwsgi |
b9f650ca | 270 | %{systemdtmpfilesdir}/%{name}.conf |
a2e939cb | 271 | %{systemdunitdir}/%{name}.service |
0eec4912 JK |
272 | %dir %{_sysconfdir}/%{name} |
273 | %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/uwsgi/emperor.ini | |
274 | %dir %{_sysconfdir}/%{name}/vassals | |
7b5bd0fa ŁC |
275 | %attr(754,root,root) /etc/rc.d/init.d/%{name} |
276 | %attr(755,uwsgi,uwsgi) %dir /var/run/uwsgi | |
277 | %attr(644,uwsgi,uwsgi) %ghost /var/log/%{name}.log | |
b698a6be JK |
278 | %dir %{_libdir}/%{name} |
279 | %{_libdir}/%{name}/cache_plugin.so | |
280 | %{_libdir}/%{name}/carbon_plugin.so | |
7565c7ee | 281 | %{_libdir}/%{name}/cgi_plugin.so |
b698a6be JK |
282 | %{_libdir}/%{name}/cheaper_busyness_plugin.so |
283 | %{_libdir}/%{name}/corerouter_plugin.so | |
284 | %{_libdir}/%{name}/fastrouter_plugin.so | |
285 | %{_libdir}/%{name}/http_plugin.so | |
286 | %{_libdir}/%{name}/logfile_plugin.so | |
287 | %{_libdir}/%{name}/logsocket_plugin.so | |
288 | %{_libdir}/%{name}/mongodblog_plugin.so | |
289 | %{_libdir}/%{name}/nagios_plugin.so | |
290 | %{_libdir}/%{name}/ping_plugin.so | |
291 | %{_libdir}/%{name}/rawrouter_plugin.so | |
292 | %{_libdir}/%{name}/redislog_plugin.so | |
293 | %{_libdir}/%{name}/router_basicauth_plugin.so | |
294 | %{_libdir}/%{name}/router_cache_plugin.so | |
295 | %{_libdir}/%{name}/router_hash_plugin.so | |
296 | %{_libdir}/%{name}/router_http_plugin.so | |
297 | %{_libdir}/%{name}/router_memcached_plugin.so | |
298 | %{_libdir}/%{name}/router_redirect_plugin.so | |
299 | %{_libdir}/%{name}/router_redis_plugin.so | |
300 | %{_libdir}/%{name}/router_rewrite_plugin.so | |
301 | %{_libdir}/%{name}/router_static_plugin.so | |
302 | %{_libdir}/%{name}/router_uwsgi_plugin.so | |
303 | %{_libdir}/%{name}/rpc_plugin.so | |
304 | %{_libdir}/%{name}/rrdtool_plugin.so | |
305 | %{_libdir}/%{name}/rsyslog_plugin.so | |
306 | %{_libdir}/%{name}/signal_plugin.so | |
307 | %{_libdir}/%{name}/spooler_plugin.so | |
308 | %{_libdir}/%{name}/sslrouter_plugin.so | |
309 | %{_libdir}/%{name}/symcall_plugin.so | |
310 | %{_libdir}/%{name}/syslog_plugin.so | |
311 | %{_libdir}/%{name}/transformation_chunked_plugin.so | |
312 | %{_libdir}/%{name}/transformation_gzip_plugin.so | |
313 | %{_libdir}/%{name}/transformation_offload_plugin.so | |
314 | %{_libdir}/%{name}/transformation_tofile_plugin.so | |
315 | %{_libdir}/%{name}/ugreen_plugin.so | |
316 | %{_libdir}/%{name}/zergpool_plugin.so | |
317 | ||
318 | %files plugin-python | |
319 | %defattr(644,root,root,755) | |
320 | %{_libdir}/%{name}/python_plugin.so | |
321 | %{_libdir}/%{name}/python%{pyver}_plugin.so | |
322 | %{_libdir}/%{name}/gevent_py%{pyver}_plugin.so | |
323 | %{_libdir}/%{name}/gevent_plugin.so | |
324 | ||
325 | %files plugin-python3 | |
326 | %defattr(644,root,root,755) | |
327 | %{_libdir}/%{name}/python3_plugin.so | |
328 | %{_libdir}/%{name}/python%{py3ver}_plugin.so | |
329 | %{_libdir}/%{name}/gevent_py%{py3ver}_plugin.so | |
330 | %{_libdir}/%{name}/gevent_py3_plugin.so |