Nginx service can not auto start

I am using nginx on redhat for a very long time, I found a service
script, installed nginx as a service to redhat, it is fine.
but I found a bug, that after dirty shutdown, nginx service can not
auto start, and i only start it by hand.
please help me, blow is the service script:

#!/bin/bash

nginx Startup script for the Nginx HTTP Server

this script create it by jackbillow at 2007.10.15.

it is v.0.0.2 version.

if you find any errors on this scripts,please contact jackbillow.

and send mail to jackbillow at gmail dot com.

chkconfig: - 85 15

description: Nginx is a high-performance web and proxy server.

It has a lot of features, but it’s not for everyone.

processname: nginx

pidfile: /usr/local/webserver/nginx/logs/nginx.pid

config: /usr/local/webserver/nginx/conf/nginx.conf

nginx=/usr/local/webserver/nginx/sbin/nginx
nginx_config=/usr/local/webserver/nginx/conf/nginx.conf
nginx_pid=/usr/local/webserver/nginx/logs/nginx.pid

RETVAL=0
prog=“nginx”

Source function library.

. /etc/rc.d/init.d/functions

Source networking configuration.

. /etc/sysconfig/network

Check that networking is up.

[ ${NETWORKING} = “no” ] && exit 0

[ -x $nginx ] || exit 0

Start nginx daemons functions.

start() {

if [ -e $nginx_pid ];then
echo “nginx already running…”
exit 1
fi

echo -n $"Starting $prog: "
daemon $nginx -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL

}

Stop nginx daemons functions.

stop() {
echo -n $"Stopping $prog: "
killproc $nginx
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx
/usr/local/webserver/nginx/logs/nginx.pid
}

reload nginx service functions.

reload() {

echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginx -HUP
RETVAL=$?
echo

}

See how we were called.

case “$1” in
start)
start
;;

stop)
stop
;;

reload)
reload
;;

restart)
stop
start
;;

status)
status $prog
RETVAL=$?
;;
*)
echo $“Usage: $prog {start|stop|restart|reload|status|help}”
exit 1
esac

exit $RETVAL

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,86637,86637#msg-86637

chkconfig nginx on

On Fri, May 14, 2010 at 9:58 PM, wangyu1314 [email protected]
wrote:

I am using nginx on redhat for a  very long time, I found a service script, installed nginx as a service to redhat, it is fine.
but I found a bug, that after dirty shutdown, Â nginx service can not auto start, and i only start it by hand.


Ren Xiaolei

Any output in log files for the service? Can you show how you start
nginx by
hand and then how the script runs (set -x)?

-peter

On 14.05.2010 16:58, wangyu1314 wrote:

I am using nginx on redhat for a very long time, I found a service script, installed nginx as a service to redhat, it is fine.
but I found a bug, that after dirty shutdown, nginx service can not auto start, and i only start it by hand.
please help me

place nginx-init.txt from attach to /etc/init.d/nginx
place nginx-sysconfig.txt from attach to /etc/sysconfig/nginx
edit path inside init script and config to yours.

start() {
if [ -e $nginx_pid ];then
echo “nginx already running…”
exit 1

bug here: $nginx_pid file exists after dirty shundown

Thanks very much, Peter Portante and Gena M…
I am testing Gena M.‘s script, if have some news i would reports
again.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,86637,86860#msg-86860

thanks.
it’s not this reason.
because i have done it:

chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig --level 345 nginx on

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,86642,86903#msg-86903

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs