10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# 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
|