Watch a GiT repository for changes
Sure, you can watch for local file changes and react to those with a
script, but can you watch for remote file changes in a
gitrepositories for you
With this simple tool combined with forever
you can create an auto updating, auto restarting server. All you need to
do to autodeploy to as many nodes as you like is
Unlike pretty much every other autodeploy tool,
assume any specific workflow, you can watch any repository and branch
you like, triggering an optional script after each update. Since that is
just a shell script, you can do what you like
superwatcher is a command line program that leverages good old
to create a series of repository watchdogs.
Seems like folks are generally in love with git hooks, which works great
except when one of your nodes is down and misses the hook and jams up
the works. Using hooks is a push method. Using
cron is a pull
method. The benefit is that nodes that are down will eventually catch up
as they pull in new changes. Self healing.
Cron is also nice in that is:
The watchdogs will leave configuration in
~/.superwatcher, just as
plain text so you can hack and poke as you see fit.
npm install -g superwatcher
Yep, you'll need node.
...get the lay of the land
These are just shell scripts, in the root of each watched repository.
Hooks wrap the auto update sequence, which goes like this:
superwatcher_before_updatecurrently on disk, this will be the prior version, not the one incoming from the remote
superwatcher_after_updatecurrently on disk, this may have been freshly pulled
Cron is nice, except when it isn't. The exact environment you get in a
cron job isn't always what you would expect, so
superwatcher lets you
set it explicitly. This will be sourced before every autoupdate
sequence, and lets you do fun stuff like pick the right
Ok, here is how you use the thing:
npm install -g superwatchersuperwatcher initsuperwatcher watch git://github.com/wballard/superwatcher.demo.git ~/demosuperwatcher environment ~/demo/environmentsuperwatcher start
At this point, everything should run. All you need to do in order to push changes is update the git repository, which is ... well, you'll need to switch to your own repository :).
You can see what is going on with:
And shut the whole thing down with:
To get a super simple, self updating server, combine
forever --watch --watchDirectory. This will give you auto update, and self restart on