class EaseEngine::Process

Public Class Methods

daemon( path, is_daemon, *args, &block ) click to toggle source
# File lib/ease_engine/process.rb, line 10
def self.daemon( path, is_daemon, *args, &block )
  pid_file_path = "#{path}.pid"
  begin
    if File.exist?( pid_file_path )
      EaseEngine::Log.err "PID file exist: #{pid_file_path}"
      break
    end
    
    ::Process.daemon( *args ) if is_daemon
    File.open( pid_file_path, "wb" ){|file|
      file.puts "#{::Process.pid}"
    }
    log_file = File.open( "#{path}.log", "a+b" )
    if ! log_file.nil?
      block.call( log_file, pid_file_path )
      log_file.close
    end
    File.delete pid_file_path if File.exist?( pid_file_path )
  end while false
end
execute( cmd, option = {} ) click to toggle source
# File lib/ease_engine/process.rb, line 5
def self.execute( cmd, option = {} )
  out, err, status = Open3.capture3( cmd, option )
  [ status.exitstatus, out, err ]
end