We are facing a strange issue with a restart_command on Chef service definition not being executed. We have a task in AWS OpsWorks that is being executed with the following service definition :
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 :
[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. So, it seems Chef is not executing this restart_command for some reason :
'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. 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. For the layers data, you would have to check that manually.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.