Rails Plugin Reloading with Passenger

I use passenger in development now. Having all of my applications ready to launch at any time makes it easier to test cross application integrations.

One problem with passenger is that even in development mode, Rails plugins are cached from request to request. This means if you edit a plugin, you won’t see the changes until you restart passenger. Since 90% of my development is on Redmine plugins, I was having to constantly restart passenger for every change I made. Fortunately, I remember rstakeout from a few years back…

rstakeout was originally written by topfunky to have a bit more control over his autotest. Basically what it does is watch a directory or files and when they change, to run a command.

This let me cobble together a script that watches the plugins on a project and restart passenger by touching tmp/restart.txt when any code changes:

1
2
3
4
# bin/watch_plugins_for_passenger.rb
#!/usr/bin/env ruby
system("touch tmp/restart.txt")
system('ruby ~/dev/rstakeout/rstakeout.rb "touch tmp/restart.txt" "vendor/**/*"')

Here’s an example run from yesterday during a marathon coding session.

=> vendor/plugins/redmine_contracts/test/integration changed, running 'touch tmp/restart.txt'

=> done
=> vendor/plugins/redmine_contracts/test/integration changed, running 'touch tmp/restart.txt'

=> done
=> vendor/plugins/redmine_contracts/test/integration/contracts_list_test.rb changed, running 'touch tmp/restart.txt'

=> done
=> vendor/plugins/redmine_contracts/test/integration changed, running 'touch tmp/restart.txt'

=> done
=> vendor/plugins/redmine_contracts/test/integration changed, running 'touch tmp/restart.txt'

=> done
=> vendor/plugins/redmine_contracts/test/integration/contracts_list_test.rb changed, running 'touch tmp/restart.txt'

=> done

To use rstakeout, you’ll need to grab the source directly as there isn’t a RubyGem for it yet. Reading topfunky’s blog post would also be good to get some other ideas about what it can be used for.

One comment

Comments are closed.