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,8 +1,8 @@
#!/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 \
# proxy and IMAP/POP3 proxy server
# processname: nginx
@ -41,7 +41,7 @@ start() {
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
killproc $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
@ -49,27 +49,26 @@ stop() {
}
restart() {
configtest || return $?
configtest_q || configtest || return 6
stop
start
}
reload() {
configtest || return $?
configtest_q || configtest || return 6
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
configtest_q() {
configtest >/dev/null 2>&1
}
rh_status() {
status $prog
}
@ -78,6 +77,29 @@ rh_status_q() {
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
start)
rh_status_q && exit 0
@ -90,20 +112,22 @@ case "$1" in
restart|configtest)
$1
;;
force-reload|upgrade)
rh_status_q || exit 7
upgrade
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
status|status_q)
rh_$1
;;
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
esac

View File

@ -9,7 +9,7 @@
Name: nginx
Version: 0.6.36
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Robust, small and high performance http and reverse proxy server
Group: System Environment/Daemons
@ -34,9 +34,7 @@ Source1: %{name}.init
Source2: %{name}.logrotate
Source3: virtual.conf
Source4: ssl.conf
Source5: nginx-upstream-fair.tgz
Source6: upstream-fair.conf
Source7: %{name}.sysconfig
Source5: %{name}.sysconfig
Source100: index.html
Source101: poweredby.png
Source102: nginx-logo.png
@ -53,17 +51,13 @@ Patch1: nginx-conf.patch
%description
Nginx [engine x] is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3
proxy server written by Igor Sysoev.
One third party module, nginx-upstream-fair, is added
proxy server written by Igor Sysoev.
%prep
%setup -q
%patch0 -p0
%patch1 -p0
%{__tar} zxvf %{SOURCE5}
%build
# nginx does not utilize a standard configure script. It has its own
@ -96,14 +90,9 @@ export DESTDIR=%{buildroot}
--with-http_perl_module \
--with-mail \
--with-mail_ssl_module \
--with-cc-opt="%{optflags} $(pcre-config --cflags)" \
--add-module=%{_builddir}/nginx-%{version}/nginx-upstream-fair
--with-cc-opt="%{optflags} $(pcre-config --cflags)"
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
rm -rf %{buildroot}
make install DESTDIR=%{buildroot} INSTALLDIRS=vendor
@ -115,15 +104,14 @@ find %{buildroot} -type f -name '*.so' -exec chmod 0755 {} \;
chmod 0755 %{buildroot}%{_sbindir}/nginx
%{__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 %{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 -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_logdir}
%{__install} -p -d -m 0755 %{buildroot}%{nginx_webroot}
%{__install} -p -m 0644 %{SOURCE100} %{SOURCE101} %{SOURCE102} %{SOURCE103} %{SOURCE104} %{buildroot}%{nginx_webroot}
# convert to UTF-8 all files that give warnings.
for textfile in CHANGES
do
@ -136,10 +124,14 @@ done
rm -rf %{buildroot}
%pre
%{_sbindir}/useradd -c "Nginx user" -s /bin/false -r -d %{nginx_home} %{nginx_user} 2>/dev/null || :
if [ $1 == 1 ]; then
%{_sbindir}/useradd -c "Nginx user" -s /bin/false -r -d %{nginx_home} %{nginx_user} 2>/dev/null || :
fi
%post
/sbin/chkconfig --add %{name}
if [ $1 == 1 ]; then
/sbin/chkconfig --add %{name}
fi
%preun
if [ $1 = 0 ]; then
@ -148,13 +140,13 @@ if [ $1 = 0 ]; then
fi
%postun
if [ $1 -ge 1 ]; then
/sbin/service %{name} condrestart > /dev/null 2>&1 || :
if [ $1 == 2 ]; then
/sbin/service %{name} upgrade || :
fi
%files
%defattr(-,root,root,-)
%doc LICENSE CHANGES README nginx-upstream-fair/README.nginx-upstream-fair
%doc LICENSE CHANGES README
%{nginx_datadir}/
%{_sbindir}/%{name}
%{_mandir}/man3/%{name}.3pm.gz
@ -182,7 +174,11 @@ fi
%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
* 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;
# }