ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

предлагаю включить в дистрибутив nginx управляющий скр ипт



Hello All,

сабж, например такой:

#!/bin/sh

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 64 36
# description: nginx.

# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $network $remote_fs
# Should-Start: ypbind nscd ldap ntpd xntpd
# Required-Stop: $local_fs $network $remote_fs
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop nginx
# Description: nginx.
### END INIT INFO


mode=$1
prefix=/usr/local/nginx
logdir=$prefix/logs

sbindir=$prefix/sbin
pid_file=$logdir/nginx.pid

#
# Use LSB init script functions for printing messages, if possible
#
lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
  source $lsb_functions
else
  log_success_msg()
  {
    echo " SUCCESS! $@"
  }
  log_failure_msg()
  {
    echo " ERROR! $@"
  }
fi

wait_for_pid () {
  i=0
  while test $i -lt 35 ; do
    sleep 1
    case "$1" in
      'created')
        test -s $pid_file && i='' && break
        ;;
      'removed')
        test ! -s $pid_file && i='' && break
        ;;
      *)
        echo "wait_for_pid () usage: wait_for_pid created|removed"
        exit 1
        ;;
    esac
    echo $echo_n ".$echo_c"
    i=`expr $i + 1`
  done

  if test -z "$i" ; then
    log_success_msg
  else
    log_failure_msg
  fi
}

case `echo "testing\c"`,`echo -n testing` in
    *c*,-n*) echo_n=   echo_c=     ;;
    *c*,*)   echo_n=-n echo_c=     ;;
    *)       echo_n=   echo_c='\c' ;;
esac


cd $prefix

case "$mode" in
  'start')
    if test -s "$pid_file"
    then
      echo "nginx is already running"
    else
      echo $echo_n "Starting nginx"
      $sbindir/nginx
      wait_for_pid created
    fi
    ;;

  'stop')
    if test -s "$pid_file"
    then
      nginx_pid=`cat $pid_file`
      echo $echo_n "Shutting down nginx"
      kill -TERM $nginx_pid
      wait_for_pid removed
    else
      log_failure_msg "nginx PID file could not be found!"
    fi
    ;;

  'restart')
    $0 stop  $other_args
    $0 start $other_args
    ;;

  'reload')
    if test -s "$pid_file" ; then
      nginx_pid=`cat $pid_file`
      kill -HUP $nginx_pid && log_success_msg "Reloading nginx"
      touch $pid_file
    else
      log_failure_msg "nginx PID file could not be found!"
    fi
    ;;

  *)
    echo "Usage: $0  {start|stop|restart|reload}"
    exit 1
    ;;
esac


его удобно будет втыкать в /etc/init.d/ в redhat подобных системах

ln -s /usr/local/nginx/bin/nginxctl /etc/init.d/nginx
chkconfig --add nginx

как это делается для подобных веб-сервисов (mysql/apache/postfix etc)

-- 
Best regards,
 Denis Latypoff                          mailto:latypoff@xxxxxxxxx




 




Copyright © Lexa Software, 1996-2009.