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
|
# File 'lib/scbi_queue_system/queued_job_list.rb', line 12
def self.execute_job(job,machine)
$LOG.info("Sending job #{job[:name]} to #{machine}")
job_path=File.join(QUEUED_PATH,job[:name])
machine_path = File.join(SENT_PATH,machine)
FileUtils.cp(job_path , File.join(RUNNING_PATH,machine))
FileUtils.mv(job_path , machine_path)
output_file=File.join(job[:cwd],job[:name]+'.out')
error_file=File.join(job[:cwd],job[:name]+'.error')
copy_cmd = "scp #{File.join(machine_path,job[:name])} #{machine}:#{job[:cwd]}"
if system(copy_cmd)
script_on_machine = File.join(job[:cwd],job[:name])
if machine.upcase.index('LOCALHOST')
launch_cmd = "nohup #{script_on_machine} </dev/null > #{output_file} 2> #{error_file} &"
else
launch_cmd = "ssh #{machine} \"nohup #{script_on_machine} </dev/null > #{output_file} 2> #{error_file} &\""
end
$LOG.info("Launch cmd: #{launch_cmd}")
if system(launch_cmd)
$LOG.info "LAUNCH DONE"
else
$LOG.error "LAUNCH FAILED: #{launch_cmd}"
end
else
$LOG.error "SCP FAILED: #{copy_cmd}"
end
end
|