Module: Pwrake::MasterApplication

Defined in:
lib/pwrake/master/master_application.rb

Overview

a mixin for managing Rake application.

Instance Method Summary collapse

Instance Method Details

#invoke_task(task_string) ⇒ Object



46
47
48
49
50
# File 'lib/pwrake/master/master_application.rb', line 46

def invoke_task(task_string)
  name, args = parse_task_string(task_string)
  t = self[name]
  @master.invoke(t,args)
end

#loggerObject



10
11
12
# File 'lib/pwrake/master/master_application.rb', line 10

def logger
  @role.logger
end

#pwrake_optionsObject



6
7
8
# File 'lib/pwrake/master/master_application.rb', line 6

def pwrake_options
  @role.option
end

#runObject

Run the Pwrake application.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pwrake/master/master_application.rb', line 23

def run
  standard_exception_handling do
    init("pwrake")  # <- parse options here
    @role = @master = Master.new
    load_rakefile
    t = Time.now
    @master.init
    @master.setup_branches
    begin
      Log.debug "init: #{Time.now-t} sec"
      t = Time.now
      top_level
      Log.debug "main: #{Time.now-t} sec"
      t = Time.now
    ensure
      @failed = @master.finish
      Log.debug "finish: #{Time.now-t} sec"
      Log.info "pwrake elapsed time: #{Time.now-START_TIME} sec"
    end
    Kernel.exit(false) if @failed
  end
end

#standard_rake_optionsObject



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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/pwrake/master/master_application.rb', line 52

def standard_rake_options
  opts = super
  opts.each_with_index do |a,i|
    if a[0] == '--version'
      a[3] = lambda { |value|
        puts "rake, version #{RAKEVERSION}"
        puts "pwrake, version #{Pwrake::VERSION}"
        exit
      }
    end
  end

  opts.concat(
  [
   ['-F', '--hostfile FILE',
    "[Pw] Read hostnames from FILE",
    lambda { |value|
      options.hostfile = value
    }
   ],
   ['-j', '--jobs [N]',
    "[Pw] Number of threads at localhost (default: # of processors)",
    lambda { |value|
      if value
        if /^[+-]?\d+$/ =~ value
          options.num_threads = value.to_i
        else
          raise ArgumentError,"Invalid argument for -j: #{value}"
        end
      else
        options.num_threads = 0
      end
    }
   ],
   ['-L', '--log', '--log-dir [DIRECTORY]', "[Pw] Write log to DIRECTORY",
    lambda { |value|
      if value.kind_of? String
        options.log_dir = value
      else
        options.log_dir = ""
      end
    }
   ],
   ['--ssh-opt', '--ssh-option OPTION', "[Pw] Option passed to SSH",
    lambda { |value|
      options.ssh_option = value
    }
   ],
   ['--filesystem FILESYSTEM', "[Pw] Specify FILESYSTEM (nfs|gfarm)",
    lambda { |value|
      options.filesystem = value
    }
   ],
   ['--gfarm', "[Pw] FILESYSTEM=gfarm",
    lambda { |value|
      options.filesystem = "gfarm"
    }
   ],
   ['-A', '--disable-affinity', "[Pw] Turn OFF affinity (AFFINITY=off)",
    lambda { |value|
      options.disable_affinity = true
    }
   ],
   ['-S', '--disable-steal', "[Pw] Turn OFF task steal",
    lambda { |value|
      options.disable_steal = true
    }
   ],
   ['-d', '--debug',
    "[Pw] Output Debug messages",
    lambda { |value|
      options.debug = true
    }
   ],
   ['--pwrake-conf [FILE]',
    "[Pw] Pwrake configuation file in YAML",
    lambda {|value| options.pwrake_conf = value}
   ],
   ['--show-conf','--show-config',
    "[Pw] Show Pwrake configuration options",
    lambda {|value| options.show_conf = true }
   ],
   ['--report LOGDIR',"[Pw] Report workflow statistics from LOGDIR to HTML and exit.",
    lambda {|value| options.report_dir = value }
   ],
   ['--clear-gfarm2fs',"[Pw] Clear gfarm2fs mountpoints left after failure.",
     lambda { |value|
       Option.new.clear_gfarm2fs
       exit
     }
   ],


  ])
  opts
end

#task_loggerObject



14
15
16
# File 'lib/pwrake/master/master_application.rb', line 14

def task_logger
  @role.task_logger
end

#task_queueObject



18
19
20
# File 'lib/pwrake/master/master_application.rb', line 18

def task_queue
  @role.task_queue
end