Class: WorkflowManager::LocalComputer
- Inherits:
-
Cluster
- Object
- Cluster
- WorkflowManager::LocalComputer
show all
- Defined in:
- lib/workflow_manager/cluster.rb
Instance Attribute Summary
Attributes inherited from Cluster
#log_dir, #name, #options
Instance Method Summary
collapse
Methods inherited from Cluster
#default_node, #generate_new_job_script, #initialize, #job_pending?, #node_list
Instance Method Details
#cluster_nodes ⇒ Object
90
91
92
|
# File 'lib/workflow_manager/cluster.rb', line 90
def cluster_nodes
{"Local Computer" => ""}
end
|
#copy_commands(org_dir, dest_parent_dir, now = nil, queue = "light") ⇒ Object
78
79
80
81
82
83
|
# File 'lib/workflow_manager/cluster.rb', line 78
def copy_commands(org_dir, dest_parent_dir, now=nil, queue="light")
commands = []
commands << "mkdir -p #{dest_parent_dir}"
commands << "cp -r #{org_dir} #{dest_parent_dir}"
commands
end
|
#delete_command(target) ⇒ Object
87
88
89
|
# File 'lib/workflow_manager/cluster.rb', line 87
def delete_command(target)
command = "rm -rf #{target}"
end
|
#job_ends?(log_file) ⇒ Boolean
73
74
75
76
77
|
# File 'lib/workflow_manager/cluster.rb', line 73
def job_ends?(log_file)
command = "tail -n 20 #{log_file}|grep '__SCRIPT END__'"
result = `#{command}`
result.to_s.empty? ? false : true
end
|
#job_running?(pid) ⇒ Boolean
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/workflow_manager/cluster.rb', line 58
def job_running?(pid)
command = "ps aux"
result = IO.popen(command) do |io|
flag = false
while line=io.gets
x = line.split
if x[1].to_i == pid.to_i
flag = true
break
end
end
flag
end
result
end
|
#kill_command(job_id) ⇒ Object
84
85
86
|
# File 'lib/workflow_manager/cluster.rb', line 84
def kill_command(job_id)
command = "kill #{job_id}"
end
|
#submit_job(script_file, script_content, option = '') ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/workflow_manager/cluster.rb', line 46
def submit_job(script_file, script_content, option='')
if script_name = File.basename(script_file) and script_name =~ /\.sh$/
new_job_script = generate_new_job_script(script_name, script_content)
new_job_script_base = File.basename(new_job_script)
log_file = File.join(@log_dir, new_job_script_base + "_o.log")
err_file = File.join(@log_dir, new_job_script_base + "_e.log")
command = "bash #{new_job_script} 1> #{log_file} 2> #{err_file}"
pid = spawn(command)
Process.detach(pid)
[pid.to_s, log_file, command]
end
end
|