lib/rexec/daemon/base.rb in rexec-1.5.0 vs lib/rexec/daemon/base.rb in rexec-1.5.1
- old
+ new
@@ -51,31 +51,31 @@
return name.gsub(/[^a-zA-Z0-9]+/, '-')
end
# The directory the daemon will run in.
def self.working_directory
- File.join(@@base_directory, daemon_name)
+ @@base_directory
end
# Return the directory to store log files in.
def self.log_directory
File.join(working_directory, "log")
end
# Standard log file for stdout and stderr.
def self.log_file_path
- File.join(log_directory, "daemon.log")
+ File.join(log_directory, "#{daemon_name}.log")
end
# Runtime data directory for the daemon.
def self.runtime_directory
File.join(working_directory, "run")
end
# Standard location of process pid file.
def self.process_file_path
- File.join(runtime_directory, "daemon.pid")
+ File.join(runtime_directory, "#{daemon_name}.pid")
end
# Mark the output log.
def self.mark_log
File.open(log_file_path, "a") do |log_file|
@@ -85,11 +85,11 @@
# Prints some information relating to daemon startup problems.
def self.tail_log(output)
lines = []
- File.open(error_log_path, "r") do |log_file|
+ File.open(log_file_path, "r") do |log_file|
log_file.seek_end
log_file.reverse_each_line do |line|
lines << line
break if line.match("=== Log Marked") || line.match("=== Daemon Exception Backtrace")
@@ -101,13 +101,13 @@
end
end
# Check the last few lines of the log file to find out if the daemon crashed.
def self.crashed?
- File.open(error_log_path, "r") do |log_file|
+ File.open(log_file_path, "r") do |log_file|
log_file.seek_end
- count = 2
+ count = 3
log_file.reverse_each_line do |line|
return true if line.match("=== Daemon Crashed")
count -= 1