Welcome! Log In Create A New Profile

Advanced

Re: nginx init script for redhat (rhel5)

mike
March 17, 2009 12:08AM
On Mon, Mar 16, 2009 at 8:44 PM, Cliff Wells <cliff@develix.com> 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 <ryan.norbauer@gmail.com>
# 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
Subject Author Posted

nginx init script for redhat (rhel5)

mike March 16, 2009 11:27PM

Re: nginx init script for redhat (rhel5)

Chris Zimmerman March 16, 2009 11:35PM

Re: nginx init script for redhat (rhel5)

mike March 16, 2009 11:37PM

Re: nginx init script for redhat (rhel5)

Chris Zimmerman March 16, 2009 11:45PM

Re: nginx init script for redhat (rhel5)

Jim Ohlstein March 16, 2009 11:36PM

Re: nginx init script for redhat (rhel5)

mike March 16, 2009 11:42PM

Re: nginx init script for redhat (rhel5)

Cliff Wells March 16, 2009 11:56PM

Re: nginx init script for redhat (rhel5)

Cliff Wells March 17, 2009 12:02AM

Re: nginx init script for redhat (rhel5)

mike March 17, 2009 12:08AM

Re: nginx init script for redhat (rhel5)

mike March 17, 2009 12:09AM

Re: nginx init script for redhat (rhel5)

Cliff Wells March 17, 2009 12:40AM

Re: nginx init script for redhat (rhel5)

mike March 17, 2009 12:43AM

Re: nginx init script for redhat (rhel5)

Jean-Philippe Moal March 17, 2009 06:07AM

Re: nginx init script for redhat (rhel5)

mike March 17, 2009 01:45PM

Re: nginx init script for redhat (rhel5)

mike March 17, 2009 12:45AM

Re: nginx init script for redhat (rhel5)

mike March 17, 2009 03:26AM

RE: nginx init script for redhat (rhel5)

Jeroen Steggink - CMS March 17, 2009 03:57AM

Re: nginx init script for redhat (rhel5)

mike March 17, 2009 04:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 83
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready