Run php script as daemon process

后端 未结 14 1593
-上瘾入骨i
-上瘾入骨i 2020-11-22 11:36

I need to run a php script as daemon process (wait for instructions and do stuff). cron job will not do it for me because actions need to be taken as soon as instruction arr

14条回答
  •  臣服心动
    2020-11-22 12:34

    I run a large number of PHP daemons.

    I agree with you that PHP is not the best (or even a good) language for doing this, but the daemons share code with the web-facing components so overall it is a good solution for us.

    We use daemontools for this. It is smart, clean and reliable. In fact we use it for running all of our daemons.

    You can check this out at http://cr.yp.to/daemontools.html.

    EDIT: A quick list of features.

    • Automatically starts the daemon on reboot
    • Automatically restart dameon on failure
    • Logging is handled for you, including rollover and pruning
    • Management interface: 'svc' and 'svstat'
    • UNIX friendly (not a plus for everyone perhaps)

提交回复
热议问题