一旦我部署完毕,delayed_job worker就会产生并正常工作-但是在大约1.5天到2天之后,它就停止工作了。
现在,我必须每天早上重新部署应用程序,以确保每天实际完成队列。我似乎无法在生产日志中找到问题所在。
这是我的脚本,用于在部署时重新启动工作线程:
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_restart_delayed_job.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
# Using similar syntax as the appdeploy pre hooks that is managed by AWS
# Loading environment data
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
EB_APP_CURRENT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
EB_APP_PIDS_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir)
# Setting up correct environment and ruby version so that bundle can load all gems
. $EB_SUPPORT_DIR/envvars
. $EB_SCRIPT_DIR/use-app-ruby.sh
# Now we can do the actual restart of the worker. Make sure to have double quotes when using env vars in the command.
# For Rails 4, replace script/delayed_job with bin/delayed_job
cd $EB_APP_CURRENT_DIR
su -s /bin/bash -c "bundle exec bin/delayed_job --pid-dir=$EB_APP_PIDS_DIR restart" $EB_APP_USER
这是生产日志,您可以看到它成功启动了工作进程,但是即使我三天前部署了该应用程序,它也没有运行任何先前的进程。
[2018-08-13T07:02:26.297Z] INFO [6232] - [Application update app-bdb6-180813_085933@169/AppDeployStage1/AppDeployPostHook/99_restart_delayed_job.sh] : Starting activity...
[2018-08-13T07:02:28.359Z] INFO [6232] - [Application update app-bdb6-180813_085933@169/AppDeployStage1/AppDeployPostHook/99_restart_delayed_job.sh] : Completed activity. Result:
`/home/webapp` is not a directory.
Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
delayed_job: warning: no instances running. Starting...
delayed_job: process with pid 8947 started.
我正在使用delayed_job (4.1.5)
和delayed_job_active_record (4.1.3)
。