ワーカーの再起動に使用されるexecute
リソースを作成します(必要に応じて調整します)。action :nothing
execute "restart_resque_workers" do
command "pkill resque && QUEUE='*' bundle exec rake environment resque:work >>/log/resque.log 2>&1 &"
cwd "/path/to/app"
action :nothing
end
次に、デプロイ リソースに以下を追加します。
application "app" do
...
notifies :run, "execute[restart_resque_workers]"
end
およびメカニズムは適切なサービスによって処理されるのが理想的ですstop
が、いずれにしても全体的なパターンは同じです。start
restart
このnotifies
属性は、application
リソースが変更された場合にのみ有効になります (通常、これは新しいデプロイを意味します)。
通知の詳細については、Chef ドキュメント を参照してください。
貧乏人のサービスは次のようになります。
service 'resque_workers' do
start = "QUEUE='*' bundle exec rake environment resque:work >>/log/resque.log 2>&1"
stop = "pkill resque"
start_command start
stop_command stop
restart_command "#{stop}; #{start}"
supports [ :start, :stop, :restart ]
end
次にnotifies :restart, "service[resque_workers]"
、application
リソースで使用します。