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