RailsConf just ended. I've got a big refactoring of RAV in the works, but until I wrap that up I'll post this to hold things over:
It may be hypocritical of me to keep harping on how it's best to avoid reliance on the mouse as much as you can, but I grudgingly admit that sometimes it is handy to be able to launch mongrel quickly with it. Below is the code for mongrel_panel.rb
:
#!/usr/bin/env ruby # Mongrel Panel # Copyright (C) 2007 Phil Hagelberg require 'gtk2' require 'gtktrayicon' RAILS_ROOT = ENV['RAILS_ROOT'] || '.' mongrel = Gtk: : TrayIcon.new("mongrel") $started = File.exist? RAILS_ROOT + '/log/mongrel.pid' button = Gtk: : Button.new("", true) button.image = Gtk: : Image.new("#{File.dirname(__FILE__)}/mong#{ \ '_mono' unless $started}.png") button.relief = Gtk: : RELIEF_NONE button.signal_connect('clicked') do if $started button.image = Gtk: : Image.new("#{File.dirname(__FILE__)}/mong_mono.png") `mongrel_rails stop -c #{RAILS_ROOT}` $started = false else button.image = Gtk: : Image.new("#{File.dirname(__FILE__)}/mong.png") `mongrel_rails start -c #{RAILS_ROOT} -d&:96; $started = true end end mongrel.add(button) mongrel.show_all Gtk.main
I feel like I keep harping on this, but man... GUI code is weird and unintuitive for me. Probably just a matter of familiarizing myself with the conventions, but still. On Ubuntu/Debian: sudo apt-get install libgnome2-ruby libgtk-trayicon-ruby1.8 then grab it.
Usage: RAILS_ROOT=~/projects/foo mongrel_panel.rb & or run it from your rails root.
This is nothing really, but it might be a nice base to adapt for other similar dæmons, I suppose. Let me know if you find it useful.
๛