lib/legion/process.rb in legionio-0.1.1 vs lib/legion/process.rb in legionio-0.2.0
- old
+ new
@@ -40,22 +40,27 @@
def info(msg)
puts "[#{::Process.pid}] [#{Time.now}] #{msg}"
end
def run!
+ start_time = Time.now
+ @options[:time_limit] = @options[:time_limit].to_i if @options.key? :time_limit
+ @quit = false
check_pid
daemonize if daemonize?
write_pid
trap_signals
until quit
sleep(1) # in real life, something productive would happen here
+ if @options.key? :time_limit
+ @quit = true if Time.now - start_time > @options[:time_limit]
+ end
end
- # sleep(1)
- # sleep(1)
Legion::Logging.info('Legion is shutting down!')
- # @service.shutdown
+ Legion.shutdown
Legion::Logging.info('Legion has shutdown. Goodbye!')
+
exit
end
#==========================================================================
# DAEMONIZING, PID MANAGEMENT, and OUTPUT REDIRECTION