nginx init script for redhat (rhel5)

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

nginx init script for redhat (rhel5)

Michael Shadle
for the most part, it works fine.

however, sometimes the pid file disappears (?)
also, "restart" does not work if the daemon is not running already. it
should handle that gracefully.

anyone have a better one? i also have the same issue with "restart" on
my ubuntu version as well...


#!/bin/sh
#
# Init file for nginx
#
# chkconfig: 2345 55 25
# description: Nginx web server
#
# processname: nginx
# config: /usr/local/nginx/nginx.conf
# pidfile: /usr/local/nginx/nginx.pid

# Description: Startup script for nginx webserver on Debian. Place in
/etc/init.d and
# run 'sudo update-rc.d nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: '/sbin/chkconfig --add nginx'
#
# Author:  Ryan Norbauer <[hidden email]>
# Modified:     Geoffrey Grosenbach http://topfunky.com
# Modified:     David Krmpotic http://davidhq.com
# Modified:                     Vishnu Gopal http://vish.in

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/sbin/nginx
CONFIGFILE=/etc/nginx/nginx.conf
PIDFILE=/var/run/nginx.pid
SCRIPTNAME=/etc/init.d/nginx

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

d_start() {
  $DAEMON -c $CONFIGFILE || echo -en "\n already running"
}

d_stop() {
  kill -QUIT `cat $PIDFILE` || echo -en "\n not running"
}

d_reload() {
  kill -HUP `cat $PIDFILE` || echo -en "\n can't reload"
}

case "$1" in
  start)
    echo -n "Starting $DESC: $NAME"
    d_start
        echo "."
  ;;
  stop)
    echo -n "Stopping $DESC: $NAME"
    d_stop
        echo "."
  ;;
  reload)
    echo -n "Reloading $DESC configuration..."
    d_reload
        echo "."
  ;;
  restart)
    echo -n "Restarting $DESC: $NAME"
    d_stop
    # One second might not be time enough for a daemon to stop,
    # if this happens, d_start will fail (and dpkg will break if
    # the package is being upgraded). Change the timeout if needed
    # be, or change d_stop to have start-stop-daemon use --retry.
    # Notice that using --retry slows down the shutdown process somewhat.
    sleep 1
    d_start
    echo "."
  ;;
  *)
    echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
    exit 3
  ;;
esac

exit 0

Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Chris Zimmerman
Better probably, not. This is what I use. At least it works.

#! /bin/sh

 
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'sudo update-rc.d nginx defaults', or use the appropriate command on your
# distro.
#
#chkconfig: 2345 55 25
#
# Author: Ryan Norbauer <[hidden email]>
# Modified: Geoffrey Grosenbach http://topfunky.com
 
set -e
 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/sbin/$NAME
CONFIGFILE=/etc/nginx/nginx.conf
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
 
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
 
d_start() {
$DAEMON -c $CONFIGFILE || echo -n " already running"
}
 
d_stop() {
kill -15 `cat $PIDFILE` || echo -n " not running"
}
 
d_reload() {
kill -15 `cat $PIDFILE` || echo -n " can't reload"
}
 
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
/etc/init.d/httpd start
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
/etc/init.d/httpd stop
;;
reload)
echo -n "Reloading $DESC configuration..."
d_reload
echo "reloaded."
/etc/init.d/httpd restart
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
# One second might not be time enough for a daemon to stop,
# if this happens, d_start will fail (and dpkg will break if
# the package is being upgraded). Change the timeout if needed
# be, or change d_stop to have start-stop-daemon use --retry.
# Notice that using --retry slows down the shutdown process somewhat.
sleep 1
d_start
echo "."
/etc/init.d/httpd restart
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
 
exit 0
Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Jim O
In reply to this post by Michael Shadle
I use this one that relies on the start stop daemon --
http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz.

After its unpacked:

$ cd apps/sys-utils/start-stop-daemon-IR1_9_18-2/
$gcc start-stop-daemon.c -o start-stop-daemon

Then copy it to /usr/local/sbin or wherever suits your fancy.

I have no issues with the pid file but it also ignores a restart request
if not running.




#! /bin/sh

### BEGIN INIT INFO
# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon
### END INIT INFO


PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/nginx
NAME=nginx
DESC=nginx

test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
         . /etc/default/nginx
fi

set -e

case "$1" in
   start)
         echo -n "Starting $DESC: "
         start-stop-daemon --start --quiet --pidfile
/usr/local/nginx/logs/$NAME.pid \
                 --exec $DAEMON -- $DAEMON_OPTS
         echo "$NAME."
         ;;
   stop)
         echo -n "Stopping $DESC: "
         start-stop-daemon --stop --quiet --pidfile
/usr/local/nginx/logs/$NAME.pid \
                 --exec $DAEMON
         echo "$NAME."
         ;;
   restart|force-reload)
         echo -n "Restarting $DESC: "
         start-stop-daemon --stop --quiet --pidfile \
                 /usr/local/nginx/logs/$NAME.pid --exec $DAEMON
         sleep 1
         start-stop-daemon --start --quiet --pidfile \
                 /usr/local/nginx/logs/$NAME.pid --exec $DAEMON --
$DAEMON_OPTS
         echo "$NAME."
         ;;
   reload)
       echo -n "Reloading $DESC configuration: "
       start-stop-daemon --stop --signal HUP --quiet --pidfile
/usr/local/nginx/logs/$NAME.pid \
           --exec $DAEMON
       echo "$NAME."
       ;;
   *)
         N=/etc/init.d/$NAME
         echo "Usage: $N {start|stop|restart|force-reload}" >&2
         exit 1
         ;;
esac

exit 0

mike wrote:

> for the most part, it works fine.
>
> however, sometimes the pid file disappears (?)
> also, "restart" does not work if the daemon is not running already. it
> should handle that gracefully.
>
> anyone have a better one? i also have the same issue with "restart" on
> my ubuntu version as well...
>
>
> #!/bin/sh
> #
> # Init file for nginx
> #
> # chkconfig: 2345 55 25
> # description: Nginx web server
> #
> # processname: nginx
> # config: /usr/local/nginx/nginx.conf
> # pidfile: /usr/local/nginx/nginx.pid
>
> # Description: Startup script for nginx webserver on Debian. Place in
> /etc/init.d and
> # run 'sudo update-rc.d nginx defaults', or use the appropriate command on your
> # distro. For CentOS/Redhat run: '/sbin/chkconfig --add nginx'
> #
> # Author:  Ryan Norbauer <[hidden email]>
> # Modified:     Geoffrey Grosenbach http://topfunky.com
> # Modified:     David Krmpotic http://davidhq.com
> # Modified:                     Vishnu Gopal http://vish.in
>
> set -e
>
> PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> DESC="nginx daemon"
> NAME=nginx
> DAEMON=/usr/sbin/nginx
> CONFIGFILE=/etc/nginx/nginx.conf
> PIDFILE=/var/run/nginx.pid
> SCRIPTNAME=/etc/init.d/nginx
>
> # Gracefully exit if the package has been removed.
> test -x $DAEMON || exit 0
>
> d_start() {
>   $DAEMON -c $CONFIGFILE || echo -en "\n already running"
> }
>
> d_stop() {
>   kill -QUIT `cat $PIDFILE` || echo -en "\n not running"
> }
>
> d_reload() {
>   kill -HUP `cat $PIDFILE` || echo -en "\n can't reload"
> }
>
> case "$1" in
>   start)
>     echo -n "Starting $DESC: $NAME"
>     d_start
>         echo "."
>   ;;
>   stop)
>     echo -n "Stopping $DESC: $NAME"
>     d_stop
>         echo "."
>   ;;
>   reload)
>     echo -n "Reloading $DESC configuration..."
>     d_reload
>         echo "."
>   ;;
>   restart)
>     echo -n "Restarting $DESC: $NAME"
>     d_stop
>     # One second might not be time enough for a daemon to stop,
>     # if this happens, d_start will fail (and dpkg will break if
>     # the package is being upgraded). Change the timeout if needed
>     # be, or change d_stop to have start-stop-daemon use --retry.
>     # Notice that using --retry slows down the shutdown process somewhat.
>     sleep 1
>     d_start
>     echo "."
>   ;;
>   *)
>     echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
>     exit 3
>   ;;
> esac
>
> exit 0
>
>

Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Michael Shadle
In reply to this post by Chris Zimmerman
looks like yours also starts /etc/init.d/httpd (most likely apache) as well?

On Mon, Mar 16, 2009 at 8:11 PM, Chris Zimmerman
<[hidden email]> wrote:

> Better probably, not. This is what I use. At least it works.
>
> #! /bin/sh
>
>
> # Description: Startup script for nginx webserver on Debian. Place in
> /etc/init.d and
> # run 'sudo update-rc.d nginx defaults', or use the appropriate command on
> your
>
> # distro.
> #
> #chkconfig: 2345 55 25
> #
> # Author: Ryan Norbauer <[hidden email]>
>
> # Modified:     Geoffrey Grosenbach http://topfunky.com
>
> set -e
>
> PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
>
> DESC="nginx daemon"
> NAME=nginx
> DAEMON=/usr/local/sbin/$NAME
>
> CONFIGFILE=/etc/nginx/nginx.conf
> PIDFILE=/var/run/$NAME.pid
>
> SCRIPTNAME=/etc/init.d/$NAME
>
> # Gracefully exit if the package has been removed.
>
> test -x $DAEMON || exit 0
>
> d_start() {
>
>   $DAEMON -c $CONFIGFILE || echo -n " already running"
>
> }
>
> d_stop() {
>   kill -15 `cat $PIDFILE` || echo -n " not running"
>
> }
>
> d_reload() {
>   kill -15 `cat $PIDFILE` || echo -n " can't reload"
>
> }
>
> case "$1" in
>   start)
>   echo -n "Starting $DESC: $NAME"
>
>   d_start
>   echo "."
>         /etc/init.d/httpd start
> ;;
>
>   stop)
>   echo -n "Stopping $DESC: $NAME"
>   d_stop
>
>   echo "."
>         /etc/init.d/httpd stop
> ;;
>   reload)
>
>   echo -n "Reloading $DESC configuration..."
>   d_reload
>   echo "reloaded."
>
>         /etc/init.d/httpd restart
>   ;;
>   restart)
>   echo -n "Restarting $DESC: $NAME"
>
>   d_stop
>   # One second might not be time enough for a daemon to stop,
>   # if this happens, d_start will fail (and dpkg will break if
>   # the package is being upgraded). Change the timeout if needed
>
>   # be, or change d_stop to have start-stop-daemon use --retry.
>   # Notice that using --retry slows down the shutdown process somewhat.
>   sleep 1
>
>   d_start
>   echo "."
>         /etc/init.d/httpd restart
> ;;
>
>   *)
>  echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
>
>  exit 3
> ;;
> esac
>
> exit 0

Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Michael Shadle
In reply to this post by Jim O
On Mon, Mar 16, 2009 at 8:15 PM, Jim Ohlstein <[hidden email]> wrote:
> I use this one that relies on the start stop daemon --
> http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz.

yeah ... i use one relatively similar for ubuntu. but i'd rather use
out-of-the-box rhel5/epel/rpmfusion supportable stuff.

when it comes down to it if i have to figure out bash script hacking
for it, so be it. just thought i'd ask.

the odd thing is when the pid file can't be found. that one will
require a killall -9 nginx i suppose. and the restart should be taken
care of as well then too.

Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Chris Zimmerman
In reply to this post by Chris Zimmerman
Err you could probably remove the httpd lines. That's for cpanel. Sorry.
Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Cliff Wells
In reply to this post by Michael Shadle
http://wiki.nginx.org/RedHatInitScript




On Mon, 2009-03-16 at 19:51 -0700, mike wrote:

> for the most part, it works fine.
>
> however, sometimes the pid file disappears (?)
> also, "restart" does not work if the daemon is not running already. it
> should handle that gracefully.
>
> anyone have a better one? i also have the same issue with "restart" on
> my ubuntu version as well...
>
>
> #!/bin/sh
> #
> # Init file for nginx
> #
> # chkconfig: 2345 55 25
> # description: Nginx web server
> #
> # processname: nginx
> # config: /usr/local/nginx/nginx.conf
> # pidfile: /usr/local/nginx/nginx.pid
>
> # Description: Startup script for nginx webserver on Debian. Place in
> /etc/init.d and
> # run 'sudo update-rc.d nginx defaults', or use the appropriate command on your
> # distro. For CentOS/Redhat run: '/sbin/chkconfig --add nginx'
> #
> # Author:  Ryan Norbauer <[hidden email]>
> # Modified:     Geoffrey Grosenbach http://topfunky.com
> # Modified:     David Krmpotic http://davidhq.com
> # Modified:                     Vishnu Gopal http://vish.in
>
> set -e
>
> PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> DESC="nginx daemon"
> NAME=nginx
> DAEMON=/usr/sbin/nginx
> CONFIGFILE=/etc/nginx/nginx.conf
> PIDFILE=/var/run/nginx.pid
> SCRIPTNAME=/etc/init.d/nginx
>
> # Gracefully exit if the package has been removed.
> test -x $DAEMON || exit 0
>
> d_start() {
>   $DAEMON -c $CONFIGFILE || echo -en "\n already running"
> }
>
> d_stop() {
>   kill -QUIT `cat $PIDFILE` || echo -en "\n not running"
> }
>
> d_reload() {
>   kill -HUP `cat $PIDFILE` || echo -en "\n can't reload"
> }
>
> case "$1" in
>   start)
>     echo -n "Starting $DESC: $NAME"
>     d_start
>         echo "."
>   ;;
>   stop)
>     echo -n "Stopping $DESC: $NAME"
>     d_stop
>         echo "."
>   ;;
>   reload)
>     echo -n "Reloading $DESC configuration..."
>     d_reload
>         echo "."
>   ;;
>   restart)
>     echo -n "Restarting $DESC: $NAME"
>     d_stop
>     # One second might not be time enough for a daemon to stop,
>     # if this happens, d_start will fail (and dpkg will break if
>     # the package is being upgraded). Change the timeout if needed
>     # be, or change d_stop to have start-stop-daemon use --retry.
>     # Notice that using --retry slows down the shutdown process somewhat.
>     sleep 1
>     d_start
>     echo "."
>   ;;
>   *)
>     echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
>     exit 3
>   ;;
> esac
>
> exit 0
>


Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Cliff Wells
Oops.  Ignore that.  Here's what I use:

http://wiki.nginx.org/RedHatNginxInitScript

Regards,
Cliff

On Mon, 2009-03-16 at 20:38 -0700, Cliff Wells wrote:

> http://wiki.nginx.org/RedHatInitScript
>
>
>
>
> On Mon, 2009-03-16 at 19:51 -0700, mike wrote:
> > for the most part, it works fine.
> >
> > however, sometimes the pid file disappears (?)
> > also, "restart" does not work if the daemon is not running already. it
> > should handle that gracefully.
> >
> > anyone have a better one? i also have the same issue with "restart" on
> > my ubuntu version as well...
> >
> >
> > #!/bin/sh
> > #
> > # Init file for nginx
> > #
> > # chkconfig: 2345 55 25
> > # description: Nginx web server
> > #
> > # processname: nginx
> > # config: /usr/local/nginx/nginx.conf
> > # pidfile: /usr/local/nginx/nginx.pid
> >
> > # Description: Startup script for nginx webserver on Debian. Place in
> > /etc/init.d and
> > # run 'sudo update-rc.d nginx defaults', or use the appropriate command on your
> > # distro. For CentOS/Redhat run: '/sbin/chkconfig --add nginx'
> > #
> > # Author:  Ryan Norbauer <[hidden email]>
> > # Modified:     Geoffrey Grosenbach http://topfunky.com
> > # Modified:     David Krmpotic http://davidhq.com
> > # Modified:                     Vishnu Gopal http://vish.in
> >
> > set -e
> >
> > PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> > DESC="nginx daemon"
> > NAME=nginx
> > DAEMON=/usr/sbin/nginx
> > CONFIGFILE=/etc/nginx/nginx.conf
> > PIDFILE=/var/run/nginx.pid
> > SCRIPTNAME=/etc/init.d/nginx
> >
> > # Gracefully exit if the package has been removed.
> > test -x $DAEMON || exit 0
> >
> > d_start() {
> >   $DAEMON -c $CONFIGFILE || echo -en "\n already running"
> > }
> >
> > d_stop() {
> >   kill -QUIT `cat $PIDFILE` || echo -en "\n not running"
> > }
> >
> > d_reload() {
> >   kill -HUP `cat $PIDFILE` || echo -en "\n can't reload"
> > }
> >
> > case "$1" in
> >   start)
> >     echo -n "Starting $DESC: $NAME"
> >     d_start
> >         echo "."
> >   ;;
> >   stop)
> >     echo -n "Stopping $DESC: $NAME"
> >     d_stop
> >         echo "."
> >   ;;
> >   reload)
> >     echo -n "Reloading $DESC configuration..."
> >     d_reload
> >         echo "."
> >   ;;
> >   restart)
> >     echo -n "Restarting $DESC: $NAME"
> >     d_stop
> >     # One second might not be time enough for a daemon to stop,
> >     # if this happens, d_start will fail (and dpkg will break if
> >     # the package is being upgraded). Change the timeout if needed
> >     # be, or change d_stop to have start-stop-daemon use --retry.
> >     # Notice that using --retry slows down the shutdown process somewhat.
> >     sleep 1
> >     d_start
> >     echo "."
> >   ;;
> >   *)
> >     echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
> >     exit 3
> >   ;;
> > esac
> >
> > exit 0
> >


Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Michael Shadle
On Mon, Mar 16, 2009 at 8:44 PM, Cliff Wells <[hidden email]> wrote:
> Oops.  Ignore that.  Here's what I use:
>
> http://wiki.nginx.org/RedHatNginxInitScript

Got that in plaintext? It wants to copy all the whitespace in my browser too :P

For sharing sake this seems to be pretty foolproof too. Should kill
off rogue instances that don't match the pidfile etc.

even "reload" will restart it if it isn't actually running.



#!/bin/sh
#
# Init file for nginx
#
# chkconfig: 2345 55 25
# description: Nginx web server
#
# processname: nginx
# config: /usr/local/nginx/nginx.conf
# pidfile: /usr/local/nginx/nginx.pid

# Description: Startup script for nginx webserver on Debian. Place in
/etc/init.d and
# run 'sudo update-rc.d nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: '/sbin/chkconfig --add nginx'
#
# Author:  Ryan Norbauer <[hidden email]>
# Modified:     Geoffrey Grosenbach http://topfunky.com
# Modified:     David Krmpotic http://davidhq.com
# Modified:                     Vishnu Gopal http://vish.in

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/sbin/nginx
CONFIGFILE=/etc/nginx/nginx.conf
PIDFILE=/var/run/nginx.pid
SCRIPTNAME=/etc/init.d/nginx

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

d_start() {
  $DAEMON -c $CONFIGFILE || echo -en "ERROR: Could not start.\n"
}

d_stop() {
  if [ -f $PIDFILE ]; then
          kill -QUIT `cat $PIDFILE` || echo -en "INFO: not running.\n"
  fi
  # force kill
  pgrep -f "nginx:" | xargs --no-run-if-empty kill -9 2>/dev/null
  rm -f $PIDFILE
}

d_reload() {
  if [ -f $PIDFILE ]; then
          kill -HUP `cat $PIDFILE` || echo -en "ERROR: can't reload.\n"
  else
          echo -en "NOTICE: can't reload, force (re)starting\n"
          $SCRIPTNAME restart
  fi
}

case "$1" in
  start)
    echo -en "Starting $DESC: $NAME\n"
    d_start
  ;;
  stop)
    echo -en "Stopping $DESC: $NAME\n"
    d_stop
  ;;
  reload)
    echo -en "Reloading $DESC configuration...\n"
    d_reload
  ;;
  restart)
    echo -en "Restarting $DESC: $NAME\n"
    d_stop
    sleep 1
    d_start
  ;;
  *)
    echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
    exit 3
  ;;
esac

exit 0

Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Michael Shadle
On Mon, Mar 16, 2009 at 8:51 PM, mike <[hidden email]> wrote:
> On Mon, Mar 16, 2009 at 8:44 PM, Cliff Wells <[hidden email]> wrote:
>> Oops.  Ignore that.  Here's what I use:
>>
>> http://wiki.nginx.org/RedHatNginxInitScript
>
> Got that in plaintext? It wants to copy all the whitespace in my browser too :P

n/m firefox to the rescue.

Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Cliff Wells
On Mon, 2009-03-16 at 20:52 -0700, mike wrote:
> On Mon, Mar 16, 2009 at 8:51 PM, mike <[hidden email]> wrote:
> > On Mon, Mar 16, 2009 at 8:44 PM, Cliff Wells <[hidden email]> wrote:
> >> Oops.  Ignore that.  Here's what I use:
> >>
> >> http://wiki.nginx.org/RedHatNginxInitScript
> >
> > Got that in plaintext? It wants to copy all the whitespace in my browser too :P
>
> n/m firefox to the rescue.


If you click the link right above the script, it should offer to
download it for you.

Cliff


Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Michael Shadle
i got it.

thanks - this seems to work even better than mine.

/me adds it to his installer

On Mon, Mar 16, 2009 at 9:20 PM, Cliff Wells <[hidden email]> wrote:

> On Mon, 2009-03-16 at 20:52 -0700, mike wrote:
>> On Mon, Mar 16, 2009 at 8:51 PM, mike <[hidden email]> wrote:
>> > On Mon, Mar 16, 2009 at 8:44 PM, Cliff Wells <[hidden email]> wrote:
>> >> Oops.  Ignore that.  Here's what I use:
>> >>
>> >> http://wiki.nginx.org/RedHatNginxInitScript
>> >
>> > Got that in plaintext? It wants to copy all the whitespace in my browser too :P
>>
>> n/m firefox to the rescue.
>
>
> If you click the link right above the script, it should offer to
> download it for you.
>
> Cliff
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Michael Shadle
Now I just need one for Ubuntu with the same amount of intelligence. :p

On Mon, Mar 16, 2009 at 9:24 PM, mike <[hidden email]> wrote:
> i got it.
>
> thanks - this seems to work even better than mine.
>
> /me adds it to his installer

Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Michael Shadle
In reply to this post by Cliff Wells
I changed this minorly

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

to include that sleep 1

it seems sometimes "stop" doesn't clean things up fast enough perhaps.
since then i have had no issues

[root@mia32217www002 build]#  service nginx restart
2009/03/16 22:48:01 [info] 2934#0: the configuration file
/etc/nginx/nginx.conf syntax is ok
2009/03/16 22:48:01 [info] 2934#0: the configuration file
/etc/nginx/nginx.conf was tested successfully Stopping nginx: [  OK  ]
Starting nginx: [  OK  ]
[root@mia32217www002 build]#  service nginx restart
2009/03/16 22:48:03 [info] 2957#0: the configuration file
/etc/nginx/nginx.conf syntax is ok
2009/03/16 22:48:03 [info] 2957#0: the configuration file
/etc/nginx/nginx.conf was tested successfully Stopping nginx: [  OK  ]
Starting nginx: [  OK  ]
[root@mia32217www002 build]#  service nginx restart
2009/03/16 22:48:03 [info] 2980#0: the configuration file
/etc/nginx/nginx.conf syntax is ok
2009/03/16 22:48:03 [info] 2980#0: the configuration file
/etc/nginx/nginx.conf was tested successfully Stopping nginx: [  OK  ]
Starting nginx:
[root@mia32217www002 build]#  service nginx restart
2009/03/16 22:49:04 [info] 3052#0: the configuration file
/etc/nginx/nginx.conf syntax is ok
2009/03/16 22:49:04 [info] 3052#0: the configuration file
/etc/nginx/nginx.conf was tested successfully Stopping nginx: [FAILED]
Starting nginx: [  OK  ]

^^ that fourth time it failed...

sleep 1 so far seems to be foolproof. my provider probably hates me
ive been restarting it over and over.


On Mon, Mar 16, 2009 at 9:20 PM, Cliff Wells <[hidden email]> wrote:

> On Mon, 2009-03-16 at 20:52 -0700, mike wrote:
>> On Mon, Mar 16, 2009 at 8:51 PM, mike <[hidden email]> wrote:
>> > On Mon, Mar 16, 2009 at 8:44 PM, Cliff Wells <[hidden email]> wrote:
>> >> Oops.  Ignore that.  Here's what I use:
>> >>
>> >> http://wiki.nginx.org/RedHatNginxInitScript
>> >
>> > Got that in plaintext? It wants to copy all the whitespace in my browser too :P
>>
>> n/m firefox to the rescue.
>
>
> If you click the link right above the script, it should offer to
> download it for you.
>
> Cliff
>
>
>

Reply | Threaded
Open this post in threaded view
|

RE: nginx init script for redhat (rhel5)

Jeroen Steggink - CMS
Hello,

I had the same problem. After adding 'sleep 1' it works.

Jeroen

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of mike
> Sent: dinsdag 17 maart 2009 7:57
> To: [hidden email]
> Subject: Re: nginx init script for redhat (rhel5)
>
> I changed this minorly
>
> restart() {
>     configtest || return $?
>     stop
>     sleep 1
>     start
> }
>
> to include that sleep 1
>
> it seems sometimes "stop" doesn't clean things up fast enough perhaps.
> since then i have had no issues
>
> [root@mia32217www002 build]#  service nginx restart
> 2009/03/16 22:48:01 [info] 2934#0: the configuration file
> /etc/nginx/nginx.conf syntax is ok
> 2009/03/16 22:48:01 [info] 2934#0: the configuration file
> /etc/nginx/nginx.conf was tested successfully Stopping nginx:
> [  OK  ] Starting nginx: [  OK  ]
> [root@mia32217www002 build]#  service nginx restart
> 2009/03/16 22:48:03 [info] 2957#0: the configuration file
> /etc/nginx/nginx.conf syntax is ok
> 2009/03/16 22:48:03 [info] 2957#0: the configuration file
> /etc/nginx/nginx.conf was tested successfully Stopping nginx:
> [  OK  ] Starting nginx: [  OK  ]
> [root@mia32217www002 build]#  service nginx restart
> 2009/03/16 22:48:03 [info] 2980#0: the configuration file
> /etc/nginx/nginx.conf syntax is ok
> 2009/03/16 22:48:03 [info] 2980#0: the configuration file
> /etc/nginx/nginx.conf was tested successfully Stopping nginx:
> [  OK  ] Starting nginx:
> [root@mia32217www002 build]#  service nginx restart
> 2009/03/16 22:49:04 [info] 3052#0: the configuration file
> /etc/nginx/nginx.conf syntax is ok
> 2009/03/16 22:49:04 [info] 3052#0: the configuration file
> /etc/nginx/nginx.conf was tested successfully Stopping nginx:
> [FAILED] Starting nginx: [  OK  ]
>
> ^^ that fourth time it failed...
>
> sleep 1 so far seems to be foolproof. my provider probably
> hates me ive been restarting it over and over.
>
>
> On Mon, Mar 16, 2009 at 9:20 PM, Cliff Wells
> <[hidden email]> wrote:
> > On Mon, 2009-03-16 at 20:52 -0700, mike wrote:
> >> On Mon, Mar 16, 2009 at 8:51 PM, mike <[hidden email]> wrote:
> >> > On Mon, Mar 16, 2009 at 8:44 PM, Cliff Wells
> <[hidden email]> wrote:
> >> >> Oops.  Ignore that.  Here's what I use:
> >> >>
> >> >> http://wiki.nginx.org/RedHatNginxInitScript
> >> >
> >> > Got that in plaintext? It wants to copy all the whitespace in my
> >> > browser too :P
> >>
> >> n/m firefox to the rescue.
> >
> >
> > If you click the link right above the script, it should offer to
> > download it for you.
> >
> > Cliff
> >
> >
> >
>
>


Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Michael Shadle
i have updated the wiki.

On Tue, Mar 17, 2009 at 12:29 AM, Jeroen Steggink - CMS
<[hidden email]> wrote:

> Hello,
>
> I had the same problem. After adding 'sleep 1' it works.
>
> Jeroen
>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]] On
>> Behalf Of mike
>> Sent: dinsdag 17 maart 2009 7:57
>> To: [hidden email]
>> Subject: Re: nginx init script for redhat (rhel5)
>>
>> I changed this minorly
>>
>> restart() {
>>     configtest || return $?
>>     stop
>>     sleep 1
>>     start
>> }
>>
>> to include that sleep 1
>>
>> it seems sometimes "stop" doesn't clean things up fast enough perhaps.
>> since then i have had no issues
>>
>> [root@mia32217www002 build]#  service nginx restart
>> 2009/03/16 22:48:01 [info] 2934#0: the configuration file
>> /etc/nginx/nginx.conf syntax is ok
>> 2009/03/16 22:48:01 [info] 2934#0: the configuration file
>> /etc/nginx/nginx.conf was tested successfully Stopping nginx:
>> [  OK  ] Starting nginx: [  OK  ]
>> [root@mia32217www002 build]#  service nginx restart
>> 2009/03/16 22:48:03 [info] 2957#0: the configuration file
>> /etc/nginx/nginx.conf syntax is ok
>> 2009/03/16 22:48:03 [info] 2957#0: the configuration file
>> /etc/nginx/nginx.conf was tested successfully Stopping nginx:
>> [  OK  ] Starting nginx: [  OK  ]
>> [root@mia32217www002 build]#  service nginx restart
>> 2009/03/16 22:48:03 [info] 2980#0: the configuration file
>> /etc/nginx/nginx.conf syntax is ok
>> 2009/03/16 22:48:03 [info] 2980#0: the configuration file
>> /etc/nginx/nginx.conf was tested successfully Stopping nginx:
>> [  OK  ] Starting nginx:
>> [root@mia32217www002 build]#  service nginx restart
>> 2009/03/16 22:49:04 [info] 3052#0: the configuration file
>> /etc/nginx/nginx.conf syntax is ok
>> 2009/03/16 22:49:04 [info] 3052#0: the configuration file
>> /etc/nginx/nginx.conf was tested successfully Stopping nginx:
>> [FAILED] Starting nginx: [  OK  ]
>>
>> ^^ that fourth time it failed...
>>
>> sleep 1 so far seems to be foolproof. my provider probably
>> hates me ive been restarting it over and over.
>>
>>
>> On Mon, Mar 16, 2009 at 9:20 PM, Cliff Wells
>> <[hidden email]> wrote:
>> > On Mon, 2009-03-16 at 20:52 -0700, mike wrote:
>> >> On Mon, Mar 16, 2009 at 8:51 PM, mike <[hidden email]> wrote:
>> >> > On Mon, Mar 16, 2009 at 8:44 PM, Cliff Wells
>> <[hidden email]> wrote:
>> >> >> Oops.  Ignore that.  Here's what I use:
>> >> >>
>> >> >> http://wiki.nginx.org/RedHatNginxInitScript
>> >> >
>> >> > Got that in plaintext? It wants to copy all the whitespace in my
>> >> > browser too :P
>> >>
>> >> n/m firefox to the rescue.
>> >
>> >
>> > If you click the link right above the script, it should offer to
>> > download it for you.
>> >
>> > Cliff
>> >
>> >
>> >
>>
>>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Jean-Philippe Moal
In reply to this post by Michael Shadle
mike a écrit :
> Now I just need one for Ubuntu with the same amount of intelligence. :p
>
> On Mon, Mar 16, 2009 at 9:24 PM, mike <[hidden email]> wrote:
>> i got it.
>>
>> thanks - this seems to work even better than mine.
>>
>> /me adds it to his installer
>

You can use debian/ubuntu one :
http://svn.debian.org/wsvn/collab-maint/deb-maint/nginx/trunk/debian/init.d?op=file&rev=0&sc=0

It works fine for me with a "custom" nginx install, you just have to edit the
path to the daemon and if necessary add a var for the PID file.

Reply | Threaded
Open this post in threaded view
|

Re: nginx init script for redhat (rhel5)

Michael Shadle
On Tue, Mar 17, 2009 at 2:43 AM, Jean-Philippe Moal
<[hidden email]> wrote:

> You can use debian/ubuntu one :
> http://svn.debian.org/wsvn/collab-maint/deb-maint/nginx/trunk/debian/init.d?op=file&rev=0&sc=0
>
> It works fine for me with a "custom" nginx install, you just have to edit the
> path to the daemon and if necessary add a var for the PID file.

I might give it a shot. I think I'd rather port Cliff's. It does a
config test on start/reload/restart, which is neat.

I'm actually using one almost identical to yours except yours has "||
true" at the end of each line:

--exec $DAEMON -- $DAEMON_OPTS || true

So I don't think it will be much different.

Or, if someone else on the list wants to take Cliff's and port it to
Ubuntu using start-stop-daemon (ideally) I'll Paypal you some cash.

(Note: payment will be done after I test it thoroughly for all
functionality in place :))