为什么80%的码农都做不了架构师?>>>
在/etc/init.d/
加入workerman
文件(自定义服务,其实就是一个bash脚本),注意不要.sh
后缀; 内部的start()
这个函数会开机启动,配合chkconfig workerman on
使用,注意引用绝对路径命令。
###一、脚本内容
#!/bin/bash#chkconfig: 2345 70 30#description: workerman command #关于脚本的简短描述#processname: workermanstart() {cd /data/wwwroot/web/workman/http/usr/local/php/bin/php http.php start -d}stop(){cd /data/wwwroot/web/workman/http/usr/local/php/bin/php http.php stop}case "$1" instart)cd /data/wwwroot/web/workman/http/usr/local/php/bin/php http.php start -decho "Starting WorkerMan...";;stop)cd /data/wwwroot/web/workman/http/usr/local/php/bin/php http.php stopecho "Shutting WorkerMan...";;restart)cd /data/wwwroot/web/workman/http/usr/local/php/bin/php http.php restartecho "Restart WorkerMan...";;reload)cd /data/wwwroot/web/workman/http/usr/local/php/bin/php http.php reloadecho "Reload WorkerMan...";;*)echo "Usage: #0 {start|stop|restart}";;esac
###二、然后加入系统服务并设置开机启动
chkconfig --add workerman chkconfig workerman on
###三、start和stop函数解释 开机会自动执行start()
函数,关机执行stop
函数
###四、使用方法 平时使用service workerman start | stop | restart | reload
###五、其他自启动方法
/etc/rc.local,在这个文件中最后加入命令即可vi ~/.bashrc 或 vi ~/.bash_profile即第一种方法