Starting /stopping nginx

hey Guys,

Anyone else notice that in the resent *.52 release stopping/starting
nginx does not restart the process? I manually have to kill -9 the
master and each child…

any ideas? it gets annoying when you have to do updates :slight_smile:
Thanks,
Payam

What’s your distro? Have you tried its mailling-lists?

HTH,
Nuno Magalhães

Hey,

Debian 5.0.1 - 2.6.18-6-k7
I was not able to find anyone having the same stop/start issues last i
checked

Thanks,

Payam Tarverdyan Chychi
Network Security Specialist / Network Engineer

2009/4/21 Nuno Magalhães [email protected]:

On Tue, Apr 21, 2009 at 09:50:09AM -0700, Payam C. wrote:

hey Guys,

Anyone else notice that in the resent *.52 release stopping/starting
nginx does not restart the process? I manually have to kill -9 the
master and each child…

BTW, why do you use stop/start instead of graceful reload ?

Hey,

I noticed that the graceful reload was not actually loading the new
config changes and so ive had to use a hard down/start

kill -quit $master works

i did also notice that nginx will not start with the following in the
config:
pid /var/log/nginx/nginx/pid;

so ive had to remove the line from the config…
so it makes sense to why i cant stop it… the pid is not able to write
to a file

-payam

2009/4/21 Igor S. [email protected]:

On Tue, Apr 21, 2009 at 01:11:45PM -0700, Payam C. wrote:

Hey,

I noticed that the graceful reload was not actually loading the new
config changes and so ive had to use a hard down/start

I never saw this. Anyway, nginx should write the reason in error_log.

kill -quit $master works

i did also notice that nginx will not start with the following in the config:
pid /var/log/nginx/nginx/pid;

Also, nginx should write the reason in error_log.

I use -QUIT only for in this sequence:

kill -USR2 cat nginx.pid # upgrade
kill -QUIT cat nginx.pid.oldbin

I use only -HUP to reload configuration

whats your start/stop script look like?

thanks,
Payam

On Tue, Apr 21, 2009 at 05:43:32PM +0000, Jim O. wrote:

I installed 0.7.52 on several Virtuozzo containers. All are running CentOS, some 32 bit and some 64. After reading your post I checked them all. One (and only one) is having a similar issue. It’s a 64 bit container. All of the others are fine and all use an identical init script.

Do you able to stop/reload nginx by head:

kill -QUIT cat /path/to/nginx.pid

?

wow i feel like a dumb dumb… re-reading what i had wrote out in the
config … i noticed i had typed in /var/log(s)/nginx… where its
/var/log/nginx…

sorry for the dumb problem guys… i thought i was going crazy and yet
it was such a stupid mistake

on a side note, anyone have a sample config of allowing proxy_pass to
attach $realip of the client to the backend origin server? My origin
sees all connections being made by my nginx proxy even though i have
x-forward set in my proxy.conf

proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;

Thanks everyone for their help…
Payam

2009/4/21 Igor S. [email protected]:

The problem sorted itself out after I (just) rebooted the container.

So I am no longer having this problem. :slight_smile:

Jim

Payam C. Wrote:

whats your start/stop script look like?

thanks,
Payam

I used to use the start-stop daemon but switched all servers to this as
I have upgraded nginx versions:

#!/bin/sh

nginx - this script starts and stops the nginx daemon

chkconfig: - 85 15

description: Nginx is an HTTP(S) server, HTTP(S) reverse \

proxy and IMAP/POP3 proxy server

processname: nginx

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

config: /etc/sysconfig/nginx

pidfile: /var/run/nginx.pid

Source function library.

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

Source networking configuration.

. /etc/sysconfig/network

Check that networking is up.

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

nginx=“/usr/local/sbin/nginx”
prog=$(basename $nginx)

NGINX_CONF_FILE=“/usr/local/nginx/conf/nginx.conf”

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}

stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {
configtest || return $?
stop
sleep 1
start
}

reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}

force_reload() {
restart
}

configtest() {
$nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}

case “$1” in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $“Usage: $0
{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}”
exit 2

------Original Message------
I was not able to find anyone having the same

What’s your distro? Have you tried its

Network Security Specialist / Network Engineer
Posted at Nginx Forum:
Re: starting /stopping nginx