I am planning the introduction of a server designed in PHP that may service socket demands. I personally use a totally free host (Heliohost) for testing, and contains cPanel. To date the only real factor I have had the opportunity to think about to possess a PHP script always running would be to write a cron job that runs a party script to check on
ps to ascertain if the PHP has already been running, and when it is not, start it.
It is possible to better way? Possibly a means for any PHP thread to become began with an HTTP request and then run in Apache following the request continues to be maintained?
You will likely not have access to success running persistent processes from Apache. It is made to prevent that scenario (though if you're able to arrive at the
fork(2) system call, it's most likely do-able). I would not recommend giving it a go though.
An amount be preferable is if you are using a host company that provides you a chance to write your personal
crontab(5) specifications and run the PHP interpreter directly. Then you may just give a line for your
@reboot /path/to/php /path/to/script.php
Your script should most likely carry out the usual daemonization tasks to ensure that
cron(8) is not stuck awaiting your process to exit.