8 %bcond_without matheval
10 %bcond_without python3
11 %bcond_without greenlet
14 %if %{without python2} && %{without python3}
15 %undefine with_greenlet
21 # - 'gevent' plugin depends on python and works only after python plugin is loaded
22 # this can probably be fixed by better linking
24 Summary: Fast WSGI server
25 Summary(pl.UTF-8): Szybki serwer WSGI
30 Group: Networking/Daemons
31 Source0: http://projects.unbit.it/downloads/%{name}-%{version}.tar.gz
32 # Source0-md5: 25107741bc7f4889a3a0f5f13b8c06de
35 Source3: %{name}.tmpfiles
36 Source4: %{name}.service
37 Patch0: shared_python.patch
38 URL: http://projects.unbit.it/uwsgi/
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
49 BuildRequires: libcap-devel
50 BuildRequires: libuuid-devel
51 BuildRequires: zlib-devel
52 BuildRequires: python-modules
54 BuildRequires: python-devel >= 1:2.7
55 %{?with_greenlet:BuildRequires: python-greenlet-devel}
58 BuildRequires: python3-devel >= 1:2.7
59 %{?with_greenlet:BuildRequires: python3-greenlet-devel}
60 BuildRequires: python3-modules
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
71 Provides: webserver(cgi)
72 Suggests: uwsgi-plugin-python
73 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
75 %define pyver %(echo %{py_ver} | tr -d .)
76 %define py3ver %(echo %{py3_ver} | tr -d .)
78 %define _noautoprovfiles %{_libdir}/%{name}/.*
81 uWSGI is a fast (pure C), self-healing, developer-friendly WSGI
82 server, aimed for professional python webapps deployment and
83 development. Over time it has evolved in a complete stack for
84 networked/clustered python applications, implementing message/object
85 passing and process management. It uses the uwsgi (all lowercase)
86 protocol for all the networking/interprocess communications. From the
87 0.9.5 release it includes a plugin loading technology that can be used
88 to add support for other languages or platform. A Lua wsapi adaptor, a
89 PSGI handler and an Erlang message exchanger are already available.
91 %package plugin-python
92 Summary: Python 2.x plugin for uWSGI
93 Group: Networking/Daemons
94 Requires: %{name} = %{version}-%{release}
96 %description plugin-python
97 Python 2.x plugin for uWSGI.
99 %package plugin-python3
100 Summary: Python 3.x plugin for uWSGI
101 Group: Networking/Daemons
102 Requires: %{name} = %{version}-%{release}
104 %description plugin-python3
105 Python 3.x plugin for uWSGI.
113 cat >buildconf/pld.ini <<EOF
118 plugin_dir = %{_libdir}/uwsgi
119 plugin_build_dir = ${PWD}
121 xml = %{?with_xml:true}%{!?with_xml:false}
122 yaml = %{?with_yaml:true}%{!?with_yaml:false}
123 zeromq = %{?with_zeromq:true}%{!?with_zeromq:false}
124 ssl = %{?with_ssl:true}%{!?with_ssl:false}
125 pcre = %{?with_pcre:true}%{!?with_pcre:false}
126 routing = %{?with_routing:true}%{!?with_routing:false}
127 matheval = %{?with_matheval:true}%{!?with_matheval:false}
128 json = %{?with_json:true}%{!?with_json:false}
130 %{?with_xml:xml_implementation = libxml2}
133 export CFLAGS="%{rpmcflags}"
134 %{__python} uwsgiconfig.py --build pld
136 # base plugin list from buildconf/base.ini
138 ping cache nagios rrdtool carbon rpc corerouter \
139 fastrouter http ugreen signal syslog rsyslog logsocket \
140 router_uwsgi router_redirect router_basicauth zergpool \
141 redislog mongodblog router_rewrite router_http logfile \
142 router_cache rawrouter router_static sslrouter spooler \
143 cheaper_busyness symcall transformation_tofile \
144 transformation_gzip transformation_chunked \
145 transformation_offload router_memcached router_redis \
146 router_hash router_expires router_metrics \
147 transformation_template stats_pusher_socket ; do
149 %{__python} uwsgiconfig.py --plugin plugins/${plugin} pld ${plugin}
152 # extra non-base plugins
153 for plugin in cgi systemd_logger ; do
154 %{__python} uwsgiconfig.py --plugin plugins/${plugin} pld ${plugin}
158 %{__python} uwsgiconfig.py --plugin plugins/python pld python%{pyver}
159 %{__python} uwsgiconfig.py --plugin plugins/gevent pld gevent_py%{pyver}
160 %{?with_greenlet:%{__python} uwsgiconfig.py --plugin plugins/greenlet pld greenlet_py%{pyver}}
163 %{__python3} uwsgiconfig.py --plugin plugins/python pld python%{py3ver}
164 %{__python3} uwsgiconfig.py --plugin plugins/gevent pld gevent_py%{py3ver}
165 %{?with_greenlet:%{__python} uwsgiconfig.py --plugin plugins/greenlet pld greenlet_py%{py3ver}}
169 rm -rf $RPM_BUILD_ROOT
170 install -d $RPM_BUILD_ROOT{%{_bindir},%{_libdir}/%{name}} \
171 $RPM_BUILD_ROOT{%{_sysconfdir}/rc.d/init.d,%{_sysconfdir}/sysconfig} \
172 $RPM_BUILD_ROOT{%{_sysconfdir}/uwsgi/vassals,/var/{run/uwsgi,log}} \
173 $RPM_BUILD_ROOT{%{systemdtmpfilesdir},%{systemdunitdir}}
175 touch $RPM_BUILD_ROOT/var/log/%{name}.log
176 install uwsgi $RPM_BUILD_ROOT%{_bindir}
177 install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/%{name}
178 install %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/uwsgi/emperor.ini
179 install %{SOURCE3} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/%{name}.conf
180 install %{SOURCE4} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service
182 install *_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}
184 # the symlinks must be absolute – otherwise strange things happen in strace
186 ln -s %{_libdir}/%{name}/python%{pyver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/python_plugin.so
187 ln -s %{_libdir}/%{name}/gevent_py%{pyver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/gevent_plugin.so
188 %{?with_greenlet:ln -s %{_libdir}/%{name}/greenlet_py%{pyver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/greenlet_plugin.so}
191 ln -s %{_libdir}/%{name}/python%{py3ver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/python3_plugin.so
192 ln -s %{_libdir}/%{name}/gevent_py%{py3ver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/gevent_py3_plugin.so
193 %{?with_greenlet:ln -s %{_libdir}/%{name}/greenlet_py%{py3ver}_plugin.so $RPM_BUILD_ROOT%{_libdir}/%{name}/greenlet_py3_plugin.so}
197 rm -rf $RPM_BUILD_ROOT
200 %groupadd -r -g 270 %{name}
201 %useradd -r -u 270 -d /usr/share/empty -s /bin/false -c "uWSGI User" -g %{name} %{name}
204 /sbin/chkconfig --add %{name}
205 touch /var/log/%{name}.log
206 chown uwsgi:uwsgi /var/log/%{name}.log
207 chmod 644 /var/log/%{name}.log
208 %service %{name} restart
209 %systemd_post %{name}.service
212 if [ "$1" = "0" ];then
213 %service %{name} stop
214 /sbin/chkconfig --del %{name}
216 %systemd_preun %{name}.service
219 if [ "$1" = "0" ]; then
225 %triggerpostun -- %{name} < 1.9.12-1.1
226 UWSGI_CONFIG_FORMAT="xml"
227 [ -f /etc/sysconfig/uwsgi.rpmsave ] && . /etc/sysconfig/uwsgi.rpmsave || :
228 if [ "$UWSGI_CONFIG_FORMAT" = "xml" ] ; then
229 if [ -f /etc/uwsgi/uwsgi.xml.rpmsave ] ; then
230 sed -e 's/<daemonize>.*<\/daemonize>//' \
231 -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>/' \
232 < /etc/uwsgi/uwsgi.xml.rpmsave \
233 > /etc/uwsgi/vassals/uwsgi.xml || :
235 cat >/etc/uwsgi/vassals/uwsgi.xml << 'EOF'
237 <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>
238 <pidfile>/var/run/uwsgi/uwsgi.pid</pidfile>
241 <socket>/var/run/uwsgi/uwsgi.sock</socket>
245 elif [ "$UWSGI_CONFIG_FORMAT" = "ini" ] ; then
246 if [ -f /etc/uwsgi/uwsgi.ini.rpmsave ] ; then
247 mv /etc/uwsgi/vassals/uwsgi.ini{,.rpmorig}
248 sed -e 's/[ \t]*daemonize.*//' \
249 -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/' \
250 < /etc/uwsgi/uwsgi.ini.rpmsave \
251 > /etc/uwsgi/vassals/uwsgi.ini || :
253 cat >/etc/uwsgi/vassals/uwsgi.ini << 'EOF'
255 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
256 socket = /var/run/uwsgi/uwsgi.sock
259 pidfile = /var/run/uwsgi/uwsgi.pid
264 if [ -f /var/run/uwsgi/uwsgi.pid ] ; then
265 # for the service restart to work
266 mv /var/run/uwsgi/uwsgi.pid /var/run/uwsgi-emperor.pid || :
269 %banner -e %{name} << 'EOF'
270 uWSGI instance configuration has been moved to
271 the %{_sysconfdir}/%{name}/vassals directory and
272 updated to be started via uWSGI emperor with loadable plugins.
274 The automatic configuration update might have failed, though.
276 You should probably install uwsgi-plugin-python too.
278 %service %{name} restart
279 %systemd_trigger %{name}.service
282 %defattr(644,root,root,755)
284 %attr(755,root,root) %{_bindir}/uwsgi
285 %{systemdtmpfilesdir}/%{name}.conf
286 %{systemdunitdir}/%{name}.service
287 %dir %{_sysconfdir}/%{name}
288 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/uwsgi/emperor.ini
289 %dir %{_sysconfdir}/%{name}/vassals
290 %attr(754,root,root) /etc/rc.d/init.d/%{name}
291 %attr(755,uwsgi,uwsgi) %dir /var/run/uwsgi
292 %attr(644,uwsgi,uwsgi) %ghost /var/log/%{name}.log
293 %dir %{_libdir}/%{name}
294 %{_libdir}/%{name}/cache_plugin.so
295 %{_libdir}/%{name}/carbon_plugin.so
296 %{_libdir}/%{name}/cgi_plugin.so
297 %{_libdir}/%{name}/cheaper_busyness_plugin.so
298 %{_libdir}/%{name}/corerouter_plugin.so
299 %{_libdir}/%{name}/fastrouter_plugin.so
300 %{_libdir}/%{name}/http_plugin.so
301 %{_libdir}/%{name}/logfile_plugin.so
302 %{_libdir}/%{name}/logsocket_plugin.so
303 %{_libdir}/%{name}/mongodblog_plugin.so
304 %{_libdir}/%{name}/nagios_plugin.so
305 %{_libdir}/%{name}/ping_plugin.so
306 %{_libdir}/%{name}/rawrouter_plugin.so
307 %{_libdir}/%{name}/redislog_plugin.so
308 %{_libdir}/%{name}/router_basicauth_plugin.so
309 %{_libdir}/%{name}/router_cache_plugin.so
310 %{_libdir}/%{name}/router_expires_plugin.so
311 %{_libdir}/%{name}/router_hash_plugin.so
312 %{_libdir}/%{name}/router_http_plugin.so
313 %{_libdir}/%{name}/router_memcached_plugin.so
314 %{_libdir}/%{name}/router_metrics_plugin.so
315 %{_libdir}/%{name}/router_redirect_plugin.so
316 %{_libdir}/%{name}/router_redis_plugin.so
317 %{_libdir}/%{name}/router_rewrite_plugin.so
318 %{_libdir}/%{name}/router_static_plugin.so
319 %{_libdir}/%{name}/router_uwsgi_plugin.so
320 %{_libdir}/%{name}/rpc_plugin.so
321 %{_libdir}/%{name}/rrdtool_plugin.so
322 %{_libdir}/%{name}/rsyslog_plugin.so
323 %{_libdir}/%{name}/signal_plugin.so
324 %{_libdir}/%{name}/spooler_plugin.so
325 %{_libdir}/%{name}/sslrouter_plugin.so
326 %{_libdir}/%{name}/stats_pusher_socket_plugin.so
327 %{_libdir}/%{name}/symcall_plugin.so
328 %{_libdir}/%{name}/syslog_plugin.so
329 %{_libdir}/%{name}/systemd_logger_plugin.so
330 %{_libdir}/%{name}/transformation_chunked_plugin.so
331 %{_libdir}/%{name}/transformation_gzip_plugin.so
332 %{_libdir}/%{name}/transformation_offload_plugin.so
333 %{_libdir}/%{name}/transformation_template_plugin.so
334 %{_libdir}/%{name}/transformation_tofile_plugin.so
335 %{_libdir}/%{name}/ugreen_plugin.so
336 %{_libdir}/%{name}/zergpool_plugin.so
339 %defattr(644,root,root,755)
340 %{_libdir}/%{name}/python_plugin.so
341 %{_libdir}/%{name}/python%{pyver}_plugin.so
342 %{_libdir}/%{name}/gevent_py%{pyver}_plugin.so
343 %{_libdir}/%{name}/gevent_plugin.so
345 %{_libdir}/%{name}/greenlet_py%{pyver}_plugin.so
346 %{_libdir}/%{name}/greenlet_plugin.so
349 %files plugin-python3
350 %defattr(644,root,root,755)
351 %{_libdir}/%{name}/python3_plugin.so
352 %{_libdir}/%{name}/python%{py3ver}_plugin.so
353 %{_libdir}/%{name}/gevent_py%{py3ver}_plugin.so
354 %{_libdir}/%{name}/gevent_py3_plugin.so
356 %{_libdir}/%{name}/greenlet_py3_plugin.so
357 %{_libdir}/%{name}/greenlet_py%{py3ver}_plugin.so