Module: CodeRunner::GenericLinux
- Defined in:
- lib/coderunner/system_modules/generic_linux.rb
Instance Method Summary collapse
- #cancel_job ⇒ Object
- #error_file ⇒ Object
- #execute ⇒ Object
- #output_file ⇒ Object
-
#queue_status ⇒ Object
@@ruby_command = "ruby1.9".
- #run_command ⇒ Object
Instance Method Details
#cancel_job ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/coderunner/system_modules/generic_linux.rb', line 63 def cancel_job children = `ps --ppid #@job_no`.scan(/^\s*(\d+)/).map{|match| match[0].to_i} system "kill #{@job_no}" children.each do |pid| system "kill #{pid}" end # `kill #{@job_no}` end |
#error_file ⇒ Object
72 73 74 |
# File 'lib/coderunner/system_modules/generic_linux.rb', line 72 def error_file return "#{executable_name}.#{job_identifier}.e" end |
#execute ⇒ Object
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 |
# File 'lib/coderunner/system_modules/generic_linux.rb', line 25 def execute log 'execute_submission' # ppipe = PPipe.new(2, false) # trap(0){} # ppipe.fork do # trap(0, 'IGNORE') # trap(2, 'IGNORE') # pid = system(run_command + " & ") # fork{exec run_command} # ppipe.w_send(:pid, pid, tp: 0) # Thread.new{Process.wait(pid)} # Need to pick up the dead process when it finishes # end # pid = ppipe.w_recv(:pid) # ppipe.die # eputs "HERE" # trap(0){} # trap(2, 'IGNORE') # pid = spawn("trap '' 2 && trap '' 0 && " + run_command + " & ") if prefix = ENV['CODE_RUNNER_LAUNCHER'] launch_id = "#{Time.now.to_i}#{$$}" fname = CodeRunner.launcher_directory + "/#{launch_id}" File.open(fname + '.start', 'w'){|file| file.puts "cd #{Dir.pwd};#{run_command}"} sleep 1 until FileTest.exist? fname + '.pid' pid = File.read(fname + '.pid').to_i FileUtils.rm fname + '.pid' else pid = Kernel.spawn(run_command + " & ") end # require 'rbconfig' # pid = spawn %[#{Config::CONFIG['bindir']}/#{Config::CONFIG['ruby_install_name']} -e 'puts fork{exec("#{run_command}")}' &] # eputs "THERE" # Thread.new{Process.wait(pid)} # sleep 0.2 return pid end |
#output_file ⇒ Object
76 77 78 |
# File 'lib/coderunner/system_modules/generic_linux.rb', line 76 def output_file return "#{executable_name}.#{job_identifier}.o" end |
#queue_status ⇒ Object
@@ruby_command = "ruby1.9"
7 8 9 10 11 12 13 14 |
# File 'lib/coderunner/system_modules/generic_linux.rb', line 7 def queue_status if rcp.uses_mpi return %x[ps -e -U #{Process.uid} | grep mpi] + %x[ps -e -U #{Process.uid} | grep -G '\\bsh\\b'] + %x[ps -e -U #{Process.uid} -o pid,user,cmd | grep coderunner].grep(/launch/) else # ep executable_name return %x[ps -e -U #{Process.uid} | grep '#{executable_name}'] + %x[ps -e -U #{Process.uid} | grep -G '\\bsh\\b'] end end |
#run_command ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/coderunner/system_modules/generic_linux.rb', line 16 def run_command if rcp.uses_mpi raise "Number of processors (nprocs) not specified" unless @nprocs return %[time mpirun -np #{@nprocs} #{executable_location}/#{executable_name} #{parameter_string} > #{output_file} 2> #{error_file}] else return %[#{executable_location}/#{executable_name} #{parameter_string} > #{output_file} 2> #{error_file}] end end |