Is there a forever.js equivalent for PHP to run my scripts continuously?

喜夏-厌秋 提交于 2019-12-09 08:20:23

问题


I occasionally use forever.js for quick and dirty deploying of CLI type Node.js applications to production environments where I don't want a full on supervisord deployment.

I was wondering if there was an equivalent for PHP? At the moment we have a queue processing system that get's messages from SQS and processes them synchronously into a database (it can't be done async as that causes all sorts of nasty row locking issues in this particular use case.) At the moment it runs ever minute using cron, but it often finishes early and I want it to start running again. I can't have more than one process running at a time.

Any *nix command/software/bash type ideas are welcome.


回答1:


Just use forever with your php script (use the -c argument to instruct forever to use php):

$ cat test.php
<?php
sleep(3);
print("foobar\n");
exit;
?>
$ forever -c php test.php
foobar
error: Forever detected script was killed by signal: null
error: Forever restarting script for 1 time
foobar
error: Forever detected script was killed by signal: null
error: Forever restarting script for 2 time
...



回答2:


I've just discovered this tool supervisord and it works great. I've used this ratchet tutorial to make it run in minutes !

If I remember correctly forever script do not restart when you reboot server ?



来源:https://stackoverflow.com/questions/18226076/is-there-a-forever-js-equivalent-for-php-to-run-my-scripts-continuously

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