nginx
几个方法
start 直接启动 查看返回值是否是0 如果0则success 非0 则failure
stop 直接调用killproc
reload 调用nginx -s reload
restart stop,start
test 调用nginx -t
status 直接调用status
几个方法killproc, status, success, failure 来自/etc/init.d/functions 详细方法:/etc/init.d/functions说明
#!/bin/bash #/etc/init.d/nginx # Source function library. if [ -f /etc/init.d/functions ] ; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 1 fi #config service='/opt/Soft/nginx/sbin/nginx' service_name='nginx' #functions start() { echo 'start service' echo "${service}" ${service} if [ "$?" -eq 0 ] ; then success else failure fi } stop() { echo 'stop service' echo "killproc ${service_name}" killproc ${service_name} } reload() { echo 'reload service' echo "${service} -s reload" ${service} -s reload if [ "$?" -eq 0 ] ; then success else failure fi } test() { echo 'test service' echo "${service} -t" ${service} -t } case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; test) test ;; status) status ${service_name} ;; *) echo "usage: $0 start|stop|reload|restart|test|status" exit 0; esacphp-fpm
start , stop ,restart|reload, status
#!/bin/bash # Source function library. if [ -f /etc/init.d/functions ] ; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 1 fi #config service='/opt/Soft/php/sbin/php-fpm' service_name='php-fpm' #functions start() { echo 'start service' echo "${service}" ${service} if [ "$?" -eq 0 ] ; then success else failure fi } stop() { echo 'stop service' echo "killproc ${service_name}" killproc ${service_name} } case "$1" in start) start ;; stop) stop ;; reload|restart) stop start ;; status) status ${service_name} ;; *) echo "usage: $0 start|stop|reload|restart|status" exit 0; esactodo:等有时间写个基于pid 和 conf的... 这样就能支持多php-fpm 了,这玩意儿先凑合用着