php消息隊列之 think queue消息隊列初體驗


  使用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/supervisor/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 #查看所有任務狀態

 

 

 

  我,秋峰,phper,目前自創業,做項目系統開發,php后端加小程序前端結合  今天就給大家分享到這里,希望對大家有所幫助。歡迎交流  大家相互學習 共同提高 我的 微信號:qiufeng2999

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM