public
Description: Run tasks and shell commands across multiple subdirectories.
Homepage:
Clone URL: git://github.com/maxim/doer.git
doer / dofile_sample
100644 94 lines (88 sloc) 2.79 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/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 .",
      :diff => "git diff",
      :test => "rake",
      :deploy => "cap deploy",
      :routes => 'rake routes',
      :sc => 'script/console',
      :watch => 'tail -f log/development.log'
    },
    :jaxer => {
      :startj => ". /Applications/Aptana_Jaxer/scripts/start.sh",
      :starts => "thin -s1 -C thin/development_config.yml --rackup thin/config.ru start",
      :stopj => ". /Applications/Aptana_Jaxer/scripts/stop.sh",
      :stops => "thin -s1 -C thin/development_config.yml --rackup thin/config.ru stop",
      :start => [:startj, :starts],
      :stop => [:stops, :stopj],
      :restartj => [:stopj, :startj],
      :restarts => [:stops, :starts],
      :cleanup => :stop,
      :sc => :skip,
      :routes => :skip,
      :status => [check_running('localhost:8081', 'Apache Server'),
                    check_running('localhost:4567', 'Sinatra Service')],
      :watch => 'tail -f log/thin.4567.log'
    },
    :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"
    },
    :docs => {
      :start => :skip,
      :stop => :skip,
      :cleanup => :skip,
      :status => :skip,
      :test => :skip,
      :deploy => :skip,
      :routes => :skip,
      :sc => :skip,
      :watch => :skip
    },
    :resources => {
      :start => :skip,
      :stop => :skip,
      :cleanup => :skip,
      :status => :skip,
      :test => :skip,
      :routes => :skip,
      :sc => :skip,
      :watch => :skip
    }
}