我需要运行一个 php 脚本作为守护进程(等待指令并做一些事情).cron 作业不会为我做这件事,因为一旦指令到达就需要采取行动.我知道由于内存管理问题,PHP 并不是守护进程的最佳选择,但由于各种原因,我必须在这种情况下使用 PHP.我遇到了 libslack 的一个名为 Daemon(libslack/daemon)的工具,它似乎对我有帮助管理守护进程,但在过去 5 年中没有任何更新,所以我想知道您是否知道其他一些适合我的情况的替代方案.任何信息将不胜感激.
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 arrives. I know PHP is not really the best option for daemon processes due to memory management issues, but due to various reasons I have to use PHP in this case. I came across a tool by libslack called Daemon (libslack/daemon) it seems to help me manage daemon processes, but there hasn't been any updates in the last 5 years, so I wonder if you know some other alternatives suitable for my case. Any information will be really appreciated.
推荐答案您可以使用
nohup php myscript.php &
& 将您的进程置于后台.
the & puts your process in the background.
是的,有一些缺点,但无法控制?那是错误的.一个简单的 kill processid 将停止它.它仍然是最好和最简单的解决方案.
Yes, there are some drawbacks, but not possible to control? That's just wrong. A simple kill processid will stop it. And it's still the best and simplest solution.
更多推荐
将 php 脚本作为守护进程运行
发布评论