Module: CodeRunner::Launcher

Included in:
Slurm
Defined in:
lib/coderunner/system_modules/launcher.rb

Overview

A module containing methods for submitting runs using the CodeRunner launcher. Typically this would be used on a home Linux system or in an interactive session on a supercomputer.

Instance Method Summary collapse

Instance Method Details

#cancel_job_launcherObject



26
27
28
29
# File 'lib/coderunner/system_modules/launcher.rb', line 26

def cancel_job_launcher
  fname = ENV['HOME'] + "/.coderunner_to_launch_#{launcher_prefix}/#{$$}.stop"
  File.open(fname, 'w'){|file| file.puts "\n"}
end

#execute_launcherObject



17
18
19
20
21
22
23
24
25
# File 'lib/coderunner/system_modules/launcher.rb', line 17

def execute_launcher
  launch_id = "#{Time.now.to_i}#{$$}"
  fname = ENV['HOME'] + "/.coderunner_to_launch_#{launcher_prefix}/#{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'
  return pid
end

#launcher_prefixObject



7
8
9
# File 'lib/coderunner/system_modules/launcher.rb', line 7

def launcher_prefix
ENV['CODE_RUNNER_LAUNCHER']
end

#queue_status_launcherObject



13
14
15
16
# File 'lib/coderunner/system_modules/launcher.rb', line 13

def queue_status_launcher
      %x[cat #{ENV['HOME']}/.coderunner_to_launch_#{launcher_prefix}/queue_status.txt]  +
      %x[cat #{ENV['HOME']}/.coderunner_to_launch_#{launcher_prefix}/queue_status2.txt] 
end

#use_launcherObject



10
11
12
# File 'lib/coderunner/system_modules/launcher.rb', line 10

def use_launcher
  launcher_prefix and launcher_prefix.size > 0
end