I'm working on a Sinatra app that uses MongoDB. I'd love to start both Sinatra and MongoDB at the same time, then kill them at the same time, too. Luckily we can use Rake's
multitask for this.
namespace :mongodb do desc "Start MongoDB for development" task :start do mkdir_p "db" system "mongod --dbpath db/" end end namespace :haystack do desc "Start Haystack for development" task :start do system "shotgun config.ru" end end desc "Start everything." multitask :start => [ 'mongodb:start', 'haystack:start' ]
Now I can start both MongoDB and my Sinatra app with
rake start. It'll run in the foreground and when I Ctrl-C, both apps will be sent the Interrupt and gracefully shutdown.