5

post-railsconf 07

 3 years ago
source link: https://technomancy.us/82
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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:

mongrel panel screenshot

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.

« older | 2007-10-13T07:00:01Z | newer »

All posts | Résumé | Projects | Talks | Colophon | Technomancy is © 2004 – 2020 Phil Hagelberg


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK