lib/daemonizer/cli.rb in daemonizer-0.4.18 vs lib/daemonizer/cli.rb in daemonizer-0.5.0.beta.1
- old
+ new
@@ -107,10 +107,23 @@
statistics = Daemonizer::Stats::MemoryStats.new(pool)
statistics.print
end
end
+ desc "logrotate", "Reopen all log files"
+ def logrotate(pool_name = nil)
+ control_pools_loop(pool_name, "log file reopened") do |pool|
+ # Pid file check
+ unless Daemonize.check_pid(pool.pid_file)
+ print_pool pool.name, "not started!"
+ exit(1)
+ end
+
+ Process.kill('HUP', Daemonize.read_pid(pool.pid_file))
+ end
+ end
+
private
def control_pools_loop(pool_name, message = nil, debug = false, &block)
if debug
pool = Daemonizer.find_pools(pool_name).first
Daemonizer.init_console_logger(pool.name.to_s)
@@ -120,10 +133,10 @@
puts "Interrupted from keyboard"
end
else
Daemonizer.find_pools(pool_name).each do |pool|
Process.fork do
- Daemonizer.init_logger(pool.name.to_s, pool.log_file)
+ Daemonizer.init_logger(pool.log_file)
yield(pool)
end
Process.wait
if $?.exitstatus == 0 and message
print_pool pool.name, message