While developing new features or bug fixes Booko, I usually work in branches. This makes keeping things separate easy, and means I can easily keep the current production version clean and easy to find. But when changing branches I often have to restart the rails server and the price grabber to pickup any changes. For example, if I’m adding a new shop in a branch, when I switch branches I want the price grabber to restart.
Turns out git makes this super easy. You just create a shell script:
That script gets called after checkout. So, mine is pretty simple:
!/bin/sh ./bin/fetch_price.rb 0 restart; thin restart
There’s probably a better way to get Thin to reload itself, but this works nicely.
You can checkout all the hooks here: http://www.kernel.org/pub/software/scm/git/docs/v188.8.131.52/hooks.html