Class: Eclipsed::Core
Overview
}}}
Direct Known Subclasses
Constant Summary
Constants included from Eclipsed
Instance Method Summary collapse
-
#all_but(index) ⇒ Object
}}} all_but {{{.
-
#attach_at(index) ⇒ Object
}}} attach_at {{{.
-
#close ⇒ Object
}}} close {{{.
-
#compile(input) ⇒ Object
compile {{{.
-
#configure ⇒ Object
Configure {{{.
-
#debug_at(index) ⇒ Object
}}} debug_at {{{.
-
#find_confpath ⇒ Object
}}} find_confpath {{{.
-
#kill(input) ⇒ Object
kill {{{.
-
#launch ⇒ Object
}}} launch {{{.
-
#pry ⇒ Object
pry {{{.
-
#restart ⇒ Object
}}} restart {{{.
-
#show ⇒ Object
}}} show {{{.
-
#submit(input) ⇒ Object
submit {{{.
Methods included from Eclipsed
Instance Method Details
#all_but(index) ⇒ Object
}}} all_but {{{
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/eclipsed.rb', line 62 def all_but(index) thr = print_async "Initializing framework..." i = 0 @nodelist.each do |node| if i != index.to_i then cmd = "ssh #{node} 'export PATH=\"#{ENV['PATH']}\"; nohup eclipse_node </dev/null &>/dev/null &'" puts cmd if @verbose system cmd unless @dryrun end i = i + 1 end thr.exit print "\r" end |
#attach_at(index) ⇒ Object
}}} attach_at {{{
102 103 104 105 106 |
# File 'lib/eclipsed.rb', line 102 def attach_at(index) cmd = "ssh #{@nodelist[index.to_i]} -t \"#{"sudo" if @sudo} gdb --pid \\`pgrep -u #{`whoami`.chomp} -x eclipse_node\\`\"" puts cmd if @verbose exec cmd unless @dryrun end |
#close ⇒ Object
}}} close {{{
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/eclipsed.rb', line 136 def close thr = print_async "Stopping framework..." user = `whoami`.chomp @nodelist.each do |node| cmd = "ssh #{node} 'pgrep -u #{user} eclipse_node &>/dev/null && kill -s SIGKILL $(ps -o pgrp= -p $(pgrep -u #{user} -x eclipse_node) | xargs echo - | tr -d [:blank:])'" puts cmd if @verbose system cmd unless @dryrun end thr.exit print "\r" end |
#compile(input) ⇒ Object
compile {{{
170 171 172 173 174 175 |
# File 'lib/eclipsed.rb', line 170 def compile(input) file_name = File.basename(input,File.extname(input)) cmd = "g++ -std=c++14 -Wall -Werror -o #{file_name} #{file_name}.cc #{@lpath} -lvmr -lvdfs -lboost_system" puts cmd if @verbose system cmd unless @dryrun end |
#configure ⇒ Object
Configure {{{
27 28 29 30 31 32 33 |
# File 'lib/eclipsed.rb', line 27 def configure json_conf = File.open(find_confpath) { |f| JSON.parse(f.read) } @nodelist = json_conf['network']['nodes'] @app_dir = json_conf['path']['applications'] #@lpath = json_conf['veloxd']['lflags'] @verbose = false end |
#debug_at(index) ⇒ Object
}}} debug_at {{{
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/eclipsed.rb', line 86 def debug_at(index) i = 0 @nodelist.each do |node| if i != index.to_i then cmd = "ssh #{node} 'export PATH=\"#{ENV['PATH']}\"; nohup eclipse_node </dev/null &>/dev/null & exit'" puts cmd system cmd end i = i + 1 end cmd = "ssh #{@nodelist[index.to_i]} -t \'export PATH=\"#{ENV['PATH']}\"; gdb --args eclipse_node \'" puts cmd if @verbose exec cmd unless @dryrun end |
#find_confpath ⇒ Object
}}} find_confpath {{{
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/eclipsed.rb', line 37 def find_confpath home = "#{ENV['HOME']}/.eclipse.json" etc = "/etc/.eclipse.json" if File.exists? home return home elsif File.exists? etc return etc end end |
#kill(input) ⇒ Object
kill {{{
148 149 150 151 152 153 154 |
# File 'lib/eclipsed.rb', line 148 def kill(input) @nodelist.each do |node| cmd = "ssh #{node} \'pkill -u #{`whoami`.chomp} #{input.join}\'" puts cmd if @verbose system cmd unless @dryrun end end |
#launch ⇒ Object
}}} launch {{{
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/eclipsed.rb', line 49 def launch thr = print_async "Initializing framework..." @nodelist.each do |node| cmd = "ssh #{node} 'export PATH=\"#{ENV['PATH']}\"; export LD_LIBRARY_PATH=\"#{ENV['LD_LIBRARY_PATH']}\"; ulimit -Sn 4000; nohup eclipse_node </dev/null &>/dev/null &'" puts cmd if @verbose system cmd unless @dryrun end thr.exit print "\r" end |
#pry ⇒ Object
pry {{{
156 157 158 159 |
# File 'lib/eclipsed.rb', line 156 def pry require 'pry' binding.pry end |
#restart ⇒ Object
}}} restart {{{
79 80 81 82 |
# File 'lib/eclipsed.rb', line 79 def restart close launch end |
#show ⇒ Object
}}} show {{{
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/eclipsed.rb', line 109 def show msg_handler = print_async "Collecting information..." instance = [ ] in_english = { true => "Running", false => "Stopped" } status = nil @nodelist.each do |node| out = nil cmd = "ssh #{node} \'pgrep -u #{`whoami`.chomp} -x eclipse_node &>/dev/null; echo $?\'" puts cmd if @verbose if `#{cmd}`.chomp == '0' out = true else out = false end mr_status = in_english[out] instance << { :host => node, :status => mr_status, :role => "worker" } end msg_handler.exit print "\r" tp instance, "host", "role", "status" end |
#submit(input) ⇒ Object
submit {{{
161 162 163 164 165 166 167 168 |
# File 'lib/eclipsed.rb', line 161 def submit(input) file_name = File.basename(input,File.extname(input)) system "g++ -c -std=c++14 -Wall -Werror -rdynamic -fpic #{input}" system "gcc -shared -fPIC -rdynamic -o #{file_name}.so #{file_name}.o" @nodelist.each do |node| system "scp #{file_name}.so #{node}:#{@app_dir}/" end end |