启动与停止
注意 Workerman 启动停止等命令都是在命令行中完成的。
要启动 Workerman,首先需要有一个启动入口文件,里面定义了服务监听的端口及协议。
这里以 workerman-chat 为例,它的启动入口为 start.php。
启动
以 debug(调试)方式启动
php start.php start
以 daemon(守护进程)方式启动
php start.php start -d
停止
php start.php stop
重启
php start.php restart
平滑重启
php start.php reload
查看状态
php start.php status
debug 和 daemon 方式区别
1、以 debug 方式启动,代码中 echo、var_dump、print 等打印函数会直接输出在终端。
2、以 daemon 方式启动,代码中 echo、var_dump、print 等打印会默认重定向到 /dev/null 文件,可以通过设置 Worker::$stdoutFile = '/your/path/file';
来设置这个文件路径。
3、以 debug 方式启动,终端关闭后 workerman 会随之关闭并退出。
4、以 daemon 方式启动,终端关闭后 workerman 继续后台正常运行。