简体   繁体   English

Amazon EC2 Linux(Elasticbeanstalk)上的PHP Upstart

[英]PHP Upstart on Amazon EC2 Linux (Elasticbeanstalk)

I have a couple of PHP scripts that I have run for ages successfully on Ubuntu (AWS EC2) as Upstart daemon services. 我有几个PHP脚本已经作为Upstart守护程序服务在Ubuntu(AWS EC2)上成功运行了很长时间。 Currently in the process of migrating the stand alone EC2 to an ElasticbeanStalk worker application. 当前正在将独立EC2迁移到ElasticbeanStalk worker应用程序。 Generally this has worked well and I have the deamons and some CRON jobs setup fine using Elasticbeanstalk extensions. 通常,此方法运行良好,并且我可以使用Elasticbeanstalk扩展名进行重传和一些CRON作业设置。 The problem I am having is the daemons are falling over. 我遇到的问题是守护进程崩溃了。 I know the PHP is fine as I can run from the command line (plus has been running well on Ubuntu). 我知道PHP很好,因为我可以从命令行运行(加上在Ubuntu上运行良好)。 Similarly I am confident my Upstart .conf file (below) is fine as it came from Ubuntu and works perfectly there. 同样,我相信我的Upstart .conf文件(如下所示)很好,因为它来自Ubuntu,并且可以在此处完美运行。 It also starts as expected but continually fails with the unhelpful "terminated with status 1" error. 它也按预期方式启动,但由于无用的“以状态1终止”错误而连续失败。 Status 1 being pretty much anything as I understand. 据我了解,状态1几乎是什么。

Extract from /var/log/messages 从/ var / log / messages中提取

Dec 31 11:33:47 ip-172-31-0-74 init: init-pulses main process (8809) terminated with status 1
Dec 31 11:33:47 ip-172-31-0-74 init: init-pulses main process ended, respawning

init-pulses.conf INIT-pulses.conf

start on filesystem and started elastic-network-interfaces
stop on shutdown
respawn
respawn limit unlimited

script
    sudo -u root php /var/www/html/index.php scripts init_pulses
end script

The PHP script contains a loop but it never hits the PHP. PHP脚本包含一个循环,但从未遇到过PHP。 There is something up with how I am executing the command although as I said this is totally cool on Ubuntu. 尽管我说过在Ubuntu上这很酷,但是我如何执行命令还是有问题的。 I have tried various forms of the same all with the same problem. 我已经尝试过各种形式的相同问题。 Can anyone offer any suggestions on how to construct the script block so it actually manages to fire the command or any ideas on how to debug this? 谁能提供任何有关如何构造脚本块的建议,以便它实际上能够触发命令或提供有关如何调试此脚本的任何想法?

Any help, as always, much appreciated 一如既往的任何帮助,不胜感激

Fixed this by removing the script block entirely and using the exec command without sudo.. 通过完全删除脚本块并使用不带sudo的exec命令来解决此问题。

start on filesystem and started elastic-network-interfaces
stop on shutdown
respawn
respawn limit unlimited
exec php /var/www/html/index.php scripts init-pulses

Simple when you know how 很简单,只要你知道

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM