I've worked with Git to accomplish this before, but require Mercurial for another project. My Git recipe included a post-receive hook
that looked like the following:
#!/bin/sh
GIT_WORK_TREE=/home/ec2-user/www
export GIT_WORK_TREE
git checkout -f
Which would refresh my working app directory every time I pushed to the remote repo on my server. I'd then run my app with node-supervisor: supervisor server.js
, which would watch for file changes and restart Node following a git push / file change.
My question is what's the best way to accomplish this with Mercurial. I've looked into the changegroup
hook as a similar alternative, but I can't find any example hooks. Thanks!
Update: My Implementation
Per answer & comment below, I went with the changegroup
hook. Specifically, in myrepo/.hg/hgrc
I used:
[hooks]
changegroup = hg update && /path/to/restart/script.sh
I went with a basic shell script to restart Node vs. installing node-supervisor per above, for this project. It looks like this:
#!/bin/sh
echo "Restarting Server" >> /logpath/server.log
sudo pkill -x node
sudo node server.js >> /logpath/server.log &
echo "Changegroup Hook Executed, Server Restarted"
exit 0
I have only one Node process running, so pkill (all) works for me. I'm also running the server.js straight out of my repo directory.