maxim / doer

Run tasks and shell commands across multiple subdirectories.

This URL has Read+Write access

doer / dofile_sample
100644 60 lines (54 sloc) 1.749 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/ruby
HERE = File.dirname(__FILE__)
 
 
# A few requires for helpers
require 'rubygems'
require 'uri'
require 'net/http'
 
 
# helpers
def check_running(host, title = '')
  Proc.new{
    begin
      Net::HTTP.get(URI.parse('http://' + host))
    rescue
      puts "#{title} (#{host})".ljust(35) + "OFF"
    else
      puts "#{title} (#{host})".ljust(35) + "RUNNING"
    end
  }
end
 
 
# commands list
PROJECTS = {
    :default => {
      :start => "script/server -d",
      :stop => "mongrel_rails stop -P tmp/pids/mongrel.pid",
      :cleanup => [:stop, "echo 'Deleting tmp/pids/mongrel.pid' && rm tmp/pids/mongrel.pid"],
      :restart => [:stop, :start],
      :status => check_running('localhost:3000'),
      :pull => "git pull origin master",
      :push => "git push origin master",
      :gs => "git status",
      :gpp => [:pull, :push],
      :gc => ["git commit -am \":message\"", %w(message)],
      :add => "echo 'Adding files to git' && git add .",
      :test => "rake",
      :deploy => "cap deploy"
    },
    :jaxer => {
      :start => "thin -s1 -C thin/development_config.yml --rackup thin/config.ru start",
      :stop => "thin -s1 -C thin/development_config.yml --rackup thin/config.ru stop",
      :cleanup => :stop,
      :status => [check_running('localhost:8081', 'Apache Server'), check_running('localhost:4567', 'Sinatra Service')]
      }
    },
    :assets => {
      :start => "script/server -p6500 -d",
      :status => check_running('localhost:6500')
    },
    :products => {
      :start => "script/server -p6600 -d",
      :status => check_running('localhost:6600')
    },
    :front => {
      :start => "script/server -p3000 -d"
    }
}