Question

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.

Was it helpful?

Solution

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
...

OTHER TIPS

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 ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top