.ebextensions 配置命令中的作业控制/后台进程(使用和号)

Ben*_*rne 7 background-process amazon-web-services elastic-beanstalk

以 .ebextensions/ 中的以下 .config 文件为例

container_commands: 
  000_run_queue_daemon: 
    command: "nohup php artisan queue:work --daemon &"
    test: "ps -ef | grep artisan | grep -v grep > /dev/null || echo 1"
Run Code Online (Sandbox Code Playgroud)

如果守护程序尚未运行,请启动队列工作器。队列工作者守护进程永远运行(按设计),因此需要作为后台进程运行。

&符号似乎没有效果,尾随 cfn-init.log 只是停在

2014-09-15 00:24:53,921 [DEBUG] Running test for command 000_run_queue_daemon
2014-09-15 00:24:53,929 [DEBUG] Test command output: 1

2014-09-15 00:24:53,929 [DEBUG] Test for command 000_run_queue_daemon passed
Run Code Online (Sandbox Code Playgroud)

然后一直如此,直到 EB 进程超时并放弃部署。

我怎样才能让它作为后台进程运行?

Ben*_*rne 8

为了完成这项工作,我必须使用部署后挂钩从文件中运行命令

commands:
  create_post_dir:
    command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
    ignoreErrors: true

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_workers.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      nohup php /var/app/current/artisan queue:work --daemon >/dev/null 2>&1 &
Run Code Online (Sandbox Code Playgroud)