Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Most of the time there's nothing new in the git repo that is deployed to a local directory, but if there are any changes, the node.js application should be restarted to start working with the latest changes. It should not be touched if no new code was pulled.

How to achieve that with chef?

share|improve this question
Can't you use the git 'post-update' hook? – Christophe Drevet-Droguet Dec 18 '12 at 12:06
up vote 2 down vote accepted

The git sync action actually triggers notifications if the revision has changed. So add an execute block that runs only on notification, and you're done!

git "/home/code" do
    action :sync
    notifies :run, "execute[restart-node-app]", :immediately

execute "restart-node-app" do
    command "..."
    action :nothing
share|improve this answer
Also check deploy resource which is more suited for deployment tasks – Poma Apr 25 '15 at 4:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.