[英]Chef service restart_command not running on AWS opsworks instnace
我們面臨着一個奇怪的問題,那就是沒有執行關於Chef服務定義的restart_command。 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
然后在通知的文件末尾調用它
elsif node[:opsworks][:instance][:layers].include?('celery-worker')
notifies :restart, resources(:service => "celery-worker-0", :service => "celery-worker-1")
從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)
但是,當我們檢查服務器本身時,芹菜工人並未重新啟動。 從服務器上的restart_command手動執行命令可以正常工作。 因此,由於某些原因,Chef似乎未執行此restart_command:
'sv force-stop celery-worker-1 ; sv start celery-worker-1'
先謝謝您的幫助。
這意味着node[:opsworks][:instance][:layers].include?('celery-worker')
為假,或者deploy_revision[testapp]
未更新。 對於后者,您可以在輸出中看到,如果您得到諸如deploy_revision[testapp] (up-to-date)
則它不會更新,因此不會觸發任何通知。 對於圖層數據,您必須手動進行檢查。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.