ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## 使用thinkphp 5的 消息队列 think queue > php think queue:listen --queue queuename > php think queue:work --daemon --queue xwyqueue 使用这两个命令进行消息队列的监控,在整个Linux操作界面关闭以后,发现就无法运行了。 原因就是这个进程没有常驻在系统后台。那么就需要用到liunx操作系统的 supervisor 来保证进程常驻 在百度搜索 supervisor 的安装 使用 然后配置 supervisor.conf 文件 ``` [program:php] command= /usr/bin/php think queue:work --queue xwyqueue --daemon ; 被监控进程 directory=/www/website/weixin/ ;process_name=%(process_num)02d ;numprocs=5 #启动几个进程 autostart=true ;随着supervisord的启动而启动 autorestart=true ;自动启动 startsecs=1 ;程序重启时候停留在runing状态的秒数 startretries=10 ;启动失败时的最多重试次数 redirect_stderr=true ;重定向stderr到stdout stdout_logfile=/root/supervisor.log ;stdout文件 ``` ## 配置好以后,启动Supervisor服务 > supervisord -c /etc/supervisord.conf 在执行命令出现以下提示信息时: Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord. For help, use /usr/bin/supervisord –h 是因为有一个使用supervisor配置的应用程序正在运行,需要执行supervisorctl shutdown命令终止 > supervisorctl status #查看所有任务状态