How do I refresh and restart a Node application with Mercurial after clicking? (Equivalent to git post-receive in hg)
I've worked with Git to accomplish this before, but require Mercurial for another project. My Git recipe included
which looked like this:
export GIT_WORK_TREE git checkout -fGIT_WORK_TREE=/home/ec2-user/www
To update my application working directory every time I move to a remote repo on my server. Then I ran my application with node-supervisor :
which will watch for file changes and restart Node after Git push / file change.
My question is the best way to achieve this with Mercurial. I've looked at hook
as a similar alternative, but I can't seem to find any examples of hooks. Thank!
Update: My implementation
In the answer and comment below, I went with a hook
. Specifically, in
[hooks] changegroup = hg update && /path/to/restart/script.sh
I went with a basic shell script to restart Node and install node-supervisor for above, for this project. It looks like this:
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 only have one Node process running, so pkill (everything) works for me. I also run server.js directly from my repo directory.
source to share