[PHP] 纯文本查看 复制代码
getManagerPid()
{
MID=`/bin/ps axu|grep zmail_server|grep manager|awk '{print $2}'`
echo $MID
}
case "$1" in
#启动服务
start)
PID=`getMasterPid`
if [ -n "$PID" ]; then
echo -n "mail server is running"
exit 1
fi
echo -n "Starting mail server "
####下面一行修改为你的php运行脚本#########
$PHP_BIN $SERVER_PATH/webroot/main.php default
echo " done"
;;
#停止服务
stop)
PID=`getMasterPid`
if [ -z "$PID" ]; then
echo -n "mail server is not running"
exit 1
fi
echo -n "Gracefully shutting down mail server "
kill $PID
echo " done"
;;
#查看运行状态
status)
PID=`getMasterPid`
if [ -n "$PID" ]; then
echo -n "mail server is running"
else
echo -n "mail server is not running"
fi
;;
#优雅退出
force-quit)
$0 stop
;;
#重启
restart)
$0 stop
$0 start
;;
reload)
MID=`getManagerPid`
if [ -z "$MID" ]; then
echo -n "mail server is not running"
exit 1
fi
echo -n "Reload service mail_server "
kill -USR1 $MID
echo " done"
;;
#只重启task进程
reloadtask)
MID=`getManagerPid`
if [ -z "$MID" ]; then
echo -n "mail server is not running"
exit 1
fi
echo -n "Reload service mail_server"
kill -USR2 $MID
echo " done"
;;
*)
echo "Usage: $0 {start|stop|force-quit|restart|reload|reloadtask|status}"
exit 1
;;
esac