Running an artisan command forever with laravel forge?

ⅰ亾dé卋堺 提交于 2020-01-04 18:09:05

问题


Can someone possibly advise how I can keep my custom artisan command running forever with the daemon?

I saw the many tutorials with queues, however it doesn't exactly fit. I am trying to accomplish "subscribe" with pubnub's php library and this seems like the best way, unless I missed something?

Thanks in advance!


回答1:


If you run the artisan command from the command line - it can already run indefinitely/forever. You dont need to do anything.

I have an application that has been running the one single artisan command for 97 days straight at the moment.

You then need to make sure it has not crashed for some reason, with something like Supervisor, or a web monitoring service like Eyewitness.io




回答2:


This will help you run artisan command forever

nohup php artisan yourcommand:abc > mylog.log 2>&1 & echo $! >> save_pid.txt

when you want to kill this process, get pid from save_pid.txt file

kill pid


来源:https://stackoverflow.com/questions/26483592/running-an-artisan-command-forever-with-laravel-forge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!