Class: Pwrake::GfarmShell
Constant Summary collapse
- @@core_id =
{}
- @@prefix =
"pwrake_#{ENV['USER']}"
Constants inherited from Shell
Shell::CHARS, Shell::OPEN_LIST, Shell::TLEN
Instance Attribute Summary
Attributes inherited from Shell
#current_task, #host, #id, #profile, #status
Instance Method Summary collapse
- #cd_work_dir ⇒ Object
- #close ⇒ Object
-
#initialize(host, opt = {}) ⇒ GfarmShell
constructor
A new instance of GfarmShell.
- #start ⇒ Object
Methods inherited from Shell
#backquote, #cd, #die, #finish, nice=, #open, profiler, reset_id, #system, #system_cmd
Constructor Details
#initialize(host, opt = {}) ⇒ GfarmShell
Returns a new instance of GfarmShell.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/pwrake/gfarm_feature.rb', line 147 def initialize(host,opt={}) super(host,opt) @single_mp = @option[:single_mp] @basedir = @option[:basedir] @prefix = @option[:prefix] || @@prefix @work_dir = @option[:work_dir] @core_id = @@core_id[host] || 0 @@core_id[host] = @core_id + 1 if @single_mp @remote_mountpoint = "#{@basedir}/#{@prefix}_00" else @remote_mountpoint = "#{@basedir}/#{@prefix}_%02d" % @core_id end end |
Instance Method Details
#cd_work_dir ⇒ Object
198 199 200 201 202 |
# File 'lib/pwrake/gfarm_feature.rb', line 198 def cd_work_dir # modify local work_dir -> remote work_dir dir = Pathname.new(@remote_mountpoint) + GfarmPath.pwd cd dir end |
#close ⇒ Object
188 189 190 191 192 193 194 195 196 |
# File 'lib/pwrake/gfarm_feature.rb', line 188 def close if @remote_mountpoint cd _system "fusermount -u #{@remote_mountpoint}" _system "rmdir #{@remote_mountpoint}" end super self end |
#start ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/pwrake/gfarm_feature.rb', line 164 def start Log.debug "--- mountpoint=#{@remote_mountpoint}" open(system_cmd) cd if not _system "test -d #{@remote_mountpoint}" _system "mkdir -p #{@remote_mountpoint}" or die else lines = _backquote("sync; mount") if /#{@remote_mountpoint} (?:type )?(\S+)/om =~ lines _system "sync; fusermount -u #{@remote_mountpoint}" _system "sync" end end subdir = GfarmPath.subdir if ["/","",nil].include?(subdir) _system "gfarm2fs #{@remote_mountpoint}" else _system "gfarm2fs -o modules=subdir,subdir=#{subdir} #{@remote_mountpoint}" end path = ENV['PATH'].gsub( /#{GfarmPath.mountpoint}/, @remote_mountpoint ) _system "export PATH=#{path}" or die cd_work_dir end |