> this script runs every minute on a cronjob, and rebuilds my site if the git repo has been updated.
He is pulling the git repo 525,600 times a year for the few commits he'll be making in that year... I guess that explains the "unusual" word?
> this script runs every minute on a cronjob, and rebuilds my site if the git repo has been updated.
He is pulling the git repo 525,600 times a year for the few commits he'll be making in that year... I guess that explains the "unusual" word?
If you want to use a callback for this I'd recommend still polling periodically anyway.
#!/bin/sh
BUILDDIR=/home/buildhook/.ib-build
BUILD=`grep build |cut -d" " -f2`
if [ -n "$BUILD" ]
then
touch $BUILDDIR/$BUILD
fi
And then the buildhook user has a job that runs every minute by cron: #!/bin/sh
BUILDDIR=/home/buildhook/.ib-build
BUILD=`ls -t $BUILDDIR | head -1`
if [ -n "$BUILD" ]
then
rm -f $BUILDDIR/$BUILD
(
echo Building $BUILD on builder...
ssh builder time ./build $BUILD
) 2>&1 | mail -s "Building $BUILD on builder" build@example.com
fi
For my use case, on this repo, pushing to a branch with the word "build" in its name will trigger a build of that commit, which builds and packages it into a dpkg, and the build server hosts a private apt repository so I can just `apt-get update; apt-get install blah` on all the servers.An alternative strategy is pushing to a different repo on a build server, etc.
Tell, don't ask.
my git repositories are all on the same server that hosts my website - git is not doing a remote fetch - it's a local fetch, which makes it basically instantaneous.
even if it were a remote fetch, i would be fine with it. 525,600 http requests per year is less wasteful than NetworkManager's heartbeat (which defaults to 1 heartbeat request per _30 seconds_ on Arch)
for some context, a stock nginx server with 8 cpus can handle ~500k+ http requests _per second_.