What's the best way to keep a PHP script running as a daemon?

后端 未结 9 1125
小蘑菇
小蘑菇 2020-12-24 03:37

What is the best way to keep a PHP script running as a daemon, and what\'s the best way to check if needs restarting.

I have some scripts that need to run 24/7 and f

9条回答
  •  -上瘾入骨i
    2020-12-24 04:39

    I agree that PHP is not the best tool for this, however I can understand why you want to use PHP so you can reuse components from your application such as database access, and so on.

    I had a similar problem and I ended up developing The Fat Controller which is a daemon written in C that can run PHP scripts. It can also run as a multithreaded daemon, running many instances of a script in parallel.

    There's more information and use cases here: http://www.4pmp.com/fatcontroller/

提交回复
热议问题