Module: Fontana::CommandUtils
- Included in:
- ServerRake
- Defined in:
- lib/fontana/command_utils.rb
Class Method Summary collapse
- .spawn_at_vendor_fontana(env, cmd, options = {}) ⇒ Object
- .spawn_at_vendor_fontana_with_sweeper(*args) ⇒ Object
- .system!(cmd) ⇒ Object
- .system_at_vendor_fontana!(cmd, &block) ⇒ Object
Class Method Details
.spawn_at_vendor_fontana(env, cmd, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/fontana/command_utils.rb', line 16 def spawn_at_vendor_fontana(env, cmd, = {}) = { chdir: FontanaClientSupport.vendor_fontana }.update() env = env.each_with_object({}){|(k,v), d| d[k.to_s] = v.to_s } puts "now spawning:\n env: #{env.inspect}\n cmd: #{cmd.inspect}\n options: #{.inspect}" pid = spawn(env, cmd, ) puts "spawning suceeded pid: #{pid.inspect}" Process.detach(pid) return pid end |
.spawn_at_vendor_fontana_with_sweeper(*args) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/fontana/command_utils.rb', line 26 def spawn_at_vendor_fontana_with_sweeper(*args) pid = spawn_at_vendor_fontana(*args) at_exit{ puts "Now killing #{pid}" Process.kill("INT", pid) } pid end |
.system!(cmd) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fontana/command_utils.rb', line 35 def system!(cmd) puts "now executing: #{cmd}" buf = [] IO.popen("#{cmd} 2>&1") do |io| while line = io.gets puts line buf << line end end if $?.exitstatus != 0 $stderr.puts("\e[31mFAILURE: %s\n%s\e[0m" % [cmd, buf.join.strip]) exit(1) end end |
.system_at_vendor_fontana!(cmd, &block) ⇒ Object
10 11 12 13 14 |
# File 'lib/fontana/command_utils.rb', line 10 def system_at_vendor_fontana!(cmd, &block) FileUtils::Verbose.chdir(FontanaClientSupport.vendor_fontana) do return system!(cmd, &block) end end |