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.
You can make it run forever by either setting the value or call set_time_limit in your script (http://php.net/manual/en/function.set-time-limit.php).
What is forever? Forever is an npm module that ensures a Node. js script continuously runs in the background on the server. It's a helpful CLI tool for the production environment because it helps manage the Node applications and their processes.
Forever is an npm package used to keep your script running continuously in the background. It's a handy CLI tool that helps you to manage your application in the development and production stages. To start running a script with forever, use the forever start command, followed by the script name.
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
...
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 ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With