init script updates from Gena Makhomed

This commit is contained in:
jjh 2009-05-17 21:11:07 +00:00
parent 6dd31739c3
commit c6fb7f86b9
4 changed files with 61 additions and 59 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# nginx - this script starts and stops the nginx daemin # nginx - this script starts and stops the nginx daemon
# #
# chkconfig: - 85 15 # chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # description: Nginx is an HTTP(S) server, HTTP(S) reverse \
@ -41,7 +41,7 @@ start() {
stop() { stop() {
echo -n $"Stopping $prog: " echo -n $"Stopping $prog: "
killproc $prog -QUIT killproc $prog
retval=$? retval=$?
echo echo
[ $retval -eq 0 ] && rm -f $lockfile [ $retval -eq 0 ] && rm -f $lockfile
@ -49,27 +49,26 @@ stop() {
} }
restart() { restart() {
configtest || return $? configtest_q || configtest || return 6
stop stop
start start
} }
reload() { reload() {
configtest || return $? configtest_q || configtest || return 6
echo -n $"Reloading $prog: " echo -n $"Reloading $prog: "
killproc $nginx -HUP killproc $nginx -HUP
RETVAL=$?
echo echo
} }
force_reload() {
restart
}
configtest() { configtest() {
$nginx -t -c $NGINX_CONF_FILE $nginx -t -c $NGINX_CONF_FILE
} }
configtest_q() {
configtest >/dev/null 2>&1
}
rh_status() { rh_status() {
status $prog status $prog
} }
@ -78,6 +77,29 @@ rh_status_q() {
rh_status >/dev/null 2>&1 rh_status >/dev/null 2>&1
} }
# Upgrade the binary with no downtime.
upgrade() {
local pidfile="/var/run/${prog}.pid"
local oldbin_pidfile="${pidfile}.oldbin"
configtest_q || configtest || return 6
echo -n $"Staring new master $prog: "
killproc $nginx -USR2
retval=$?
echo
sleep 1
if [[ -f ${oldbin_pidfile} && -f ${pidfile} ]]; then
echo -n $"Graceful shutdown of old $prog: "
killproc -p ${oldbin_pidfile} -QUIT
retval=$?
echo
return 0
else
echo $"Something bad happened, manual intervention required, maybe restart?"
return 1
fi
}
case "$1" in case "$1" in
start) start)
rh_status_q && exit 0 rh_status_q && exit 0
@ -90,20 +112,22 @@ case "$1" in
restart|configtest) restart|configtest)
$1 $1
;; ;;
force-reload|upgrade)
rh_status_q || exit 7
upgrade
;;
reload) reload)
rh_status_q || exit 7 rh_status_q || exit 7
$1 $1
;; ;;
force-reload) status|status_q)
force_reload rh_$1
;;
status)
rh_status
;; ;;
condrestart|try-restart) condrestart|try-restart)
rh_status_q || exit 0 rh_status_q || exit 7
restart
;; ;;
*) *)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" echo $"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart}"
exit 2 exit 2
esac esac

View File

@ -9,7 +9,7 @@
Name: nginx Name: nginx
Version: 0.6.36 Version: 0.6.36
Release: 1%{?dist} Release: 2%{?dist}
Summary: Robust, small and high performance http and reverse proxy server Summary: Robust, small and high performance http and reverse proxy server
Group: System Environment/Daemons Group: System Environment/Daemons
@ -34,9 +34,7 @@ Source1: %{name}.init
Source2: %{name}.logrotate Source2: %{name}.logrotate
Source3: virtual.conf Source3: virtual.conf
Source4: ssl.conf Source4: ssl.conf
Source5: nginx-upstream-fair.tgz Source5: %{name}.sysconfig
Source6: upstream-fair.conf
Source7: %{name}.sysconfig
Source100: index.html Source100: index.html
Source101: poweredby.png Source101: poweredby.png
Source102: nginx-logo.png Source102: nginx-logo.png
@ -55,15 +53,11 @@ Patch1: nginx-conf.patch
Nginx [engine x] is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 Nginx [engine x] is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3
proxy server written by Igor Sysoev. proxy server written by Igor Sysoev.
One third party module, nginx-upstream-fair, is added
%prep %prep
%setup -q %setup -q
%patch0 -p0 %patch0 -p0
%patch1 -p0 %patch1 -p0
%{__tar} zxvf %{SOURCE5}
%build %build
# nginx does not utilize a standard configure script. It has its own # nginx does not utilize a standard configure script. It has its own
@ -96,14 +90,9 @@ export DESTDIR=%{buildroot}
--with-http_perl_module \ --with-http_perl_module \
--with-mail \ --with-mail \
--with-mail_ssl_module \ --with-mail_ssl_module \
--with-cc-opt="%{optflags} $(pcre-config --cflags)" \ --with-cc-opt="%{optflags} $(pcre-config --cflags)"
--add-module=%{_builddir}/nginx-%{version}/nginx-upstream-fair
make %{?_smp_mflags} make %{?_smp_mflags}
# rename the readme for nginx-upstream-fair so it doesn't conflict with the main
# readme
mv nginx-upstream-fair/README nginx-upstream-fair/README.nginx-upstream-fair
%install %install
rm -rf %{buildroot} rm -rf %{buildroot}
make install DESTDIR=%{buildroot} INSTALLDIRS=vendor make install DESTDIR=%{buildroot} INSTALLDIRS=vendor
@ -115,15 +104,14 @@ find %{buildroot} -type f -name '*.so' -exec chmod 0755 {} \;
chmod 0755 %{buildroot}%{_sbindir}/nginx chmod 0755 %{buildroot}%{_sbindir}/nginx
%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name} %{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name}
%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} %{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%{__install} -p -D -m 0644 %{SOURCE7} %{buildroot}%{_sysconfdir}/sysconfig/%{name} %{__install} -p -D -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
%{__install} -p -d -m 0755 %{buildroot}%{nginx_confdir}/conf.d %{__install} -p -d -m 0755 %{buildroot}%{nginx_confdir}/conf.d
%{__install} -p -m 0644 %{SOURCE3} %{SOURCE4} %{SOURCE6} %{buildroot}%{nginx_confdir}/conf.d %{__install} -p -m 0644 %{SOURCE3} %{SOURCE4} %{buildroot}%{nginx_confdir}/conf.d
%{__install} -p -d -m 0755 %{buildroot}%{nginx_home_tmp} %{__install} -p -d -m 0755 %{buildroot}%{nginx_home_tmp}
%{__install} -p -d -m 0755 %{buildroot}%{nginx_logdir} %{__install} -p -d -m 0755 %{buildroot}%{nginx_logdir}
%{__install} -p -d -m 0755 %{buildroot}%{nginx_webroot} %{__install} -p -d -m 0755 %{buildroot}%{nginx_webroot}
%{__install} -p -m 0644 %{SOURCE100} %{SOURCE101} %{SOURCE102} %{SOURCE103} %{SOURCE104} %{buildroot}%{nginx_webroot} %{__install} -p -m 0644 %{SOURCE100} %{SOURCE101} %{SOURCE102} %{SOURCE103} %{SOURCE104} %{buildroot}%{nginx_webroot}
# convert to UTF-8 all files that give warnings. # convert to UTF-8 all files that give warnings.
for textfile in CHANGES for textfile in CHANGES
do do
@ -136,10 +124,14 @@ done
rm -rf %{buildroot} rm -rf %{buildroot}
%pre %pre
if [ $1 == 1 ]; then
%{_sbindir}/useradd -c "Nginx user" -s /bin/false -r -d %{nginx_home} %{nginx_user} 2>/dev/null || : %{_sbindir}/useradd -c "Nginx user" -s /bin/false -r -d %{nginx_home} %{nginx_user} 2>/dev/null || :
fi
%post %post
if [ $1 == 1 ]; then
/sbin/chkconfig --add %{name} /sbin/chkconfig --add %{name}
fi
%preun %preun
if [ $1 = 0 ]; then if [ $1 = 0 ]; then
@ -148,13 +140,13 @@ if [ $1 = 0 ]; then
fi fi
%postun %postun
if [ $1 -ge 1 ]; then if [ $1 == 2 ]; then
/sbin/service %{name} condrestart > /dev/null 2>&1 || : /sbin/service %{name} upgrade || :
fi fi
%files %files
%defattr(-,root,root,-) %defattr(-,root,root,-)
%doc LICENSE CHANGES README nginx-upstream-fair/README.nginx-upstream-fair %doc LICENSE CHANGES README
%{nginx_datadir}/ %{nginx_datadir}/
%{_sbindir}/%{name} %{_sbindir}/%{name}
%{_mandir}/man3/%{name}.3pm.gz %{_mandir}/man3/%{name}.3pm.gz
@ -182,7 +174,11 @@ fi
%changelog %changelog
* Sat Apr 11 2009 Jeremy Hinegardner <jeremy at hinegardner dot org> 0.6.36-1 * Sun May 17 2009 Jeremy Hinegardner <jeremy at hinegardner dot org> - 0.6.36-2
- init script updates from Gena Makhomed
- remove nginx-upstream-fair
* Sat Apr 11 2009 Jeremy Hinegardner <jeremy at hinegardner dot org> - 0.6.36-1
- update to 0.6.36 - update to 0.6.36
* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.35-3 * Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.35-3

View File

@ -1,18 +0,0 @@
#
# This is a sample configuration to use the nginx-upstream-fair module
# that is included.
#
# http://wiki.codemongers.com/NginxHttpUpstreamFairModule
#
# Change your Nginx config file's upstream block to include the 'fair'
# directive:
#
# upstream mongrel {
# fair;
# server 127.0.0.1:5000;
# server 127.0.0.1:5001;
# server 127.0.0.1:5002;
# }