[英]Chef service restart_command not running on AWS opsworks instnace
We are facing a strange issue with a restart_command on Chef service definition not being executed. 我们面临着一个奇怪的问题,那就是没有执行关于Chef服务定义的restart_command。 We have a task in AWS OpsWorks that is being executed with the following service definition :
AWS OpsWorks中有一个任务正在使用以下服务定义执行:
service "celery-worker-1" do
action [ :nothing ]
supports :restart=>true, :status=>true
retries 3
restart_command 'sv force-stop celery-worker-1 ; sv start celery-worker-1'
if node[:opsworks][:instance][:layers].include?('celery-worker')
subscribes :restart, "deploy_revision[testapp]", :delayed
end
end
Then this is called at the end of the file from notifies 然后在通知的文件末尾调用它
elsif node[:opsworks][:instance][:layers].include?('celery-worker')
notifies :restart, resources(:service => "celery-worker-0", :service => "celery-worker-1")
When this task is executed from OpsWorks the logs show no errors or issues : 从OpsWorks执行此任务时,日志不会显示任何错误或问题:
[2018-02-09T08:33:34+00:00] INFO: Processing service[celery-worker-0] action nothing (testapp::configure line 17)
[2018-02-09T08:33:34+00:00] INFO: Processing service[celery-worker-1] action nothing (testapp::configure line 27)
But when we check on the server itself the celery-workers were not restarted. 但是,当我们检查服务器本身时,芹菜工人并未重新启动。 Executing manually the command from restart_command on the server, works without any issues.
从服务器上的restart_command手动执行命令可以正常工作。 So, it seems Chef is not executing this restart_command for some reason :
因此,由于某些原因,Chef似乎未执行此restart_command:
'sv force-stop celery-worker-1 ; sv start celery-worker-1'
Thanks in advance for the help. 先谢谢您的帮助。
That would mean that either node[:opsworks][:instance][:layers].include?('celery-worker')
is false or deploy_revision[testapp]
is not updating. 这意味着
node[:opsworks][:instance][:layers].include?('celery-worker')
为假,或者deploy_revision[testapp]
未更新。 For the latter you can see in the output, if you get something like deploy_revision[testapp] (up-to-date)
then it isn't updating so no notification trigger. 对于后者,您可以在输出中看到,如果您得到诸如
deploy_revision[testapp] (up-to-date)
则它不会更新,因此不会触发任何通知。 For the layers data, you would have to check that manually. 对于图层数据,您必须手动进行检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.