add start|stop|restart|run to crono executable

this is done using daemonize gem, but it is not breaking the old
interface. But sets a deprected comment to the old one daemonize
process.
This commit is contained in:
Jannis Hübl
2016-01-15 11:03:38 +01:00
parent 6881109934
commit 0affff21d1
6 changed files with 165 additions and 19 deletions
+15 -2
View File
@@ -4,18 +4,31 @@ module Crono
CRONOTAB = 'config/cronotab.rb'
LOGFILE = 'log/crono.log'
PIDFILE = 'tmp/pids/crono.pid'
PIDDIR = 'tmp/pids'
PROCESS_NAME = 'crono'
attr_accessor :cronotab, :logfile, :pidfile, :daemonize, :environment
attr_accessor :cronotab, :logfile, :pidfile, :piddir, :process_name,
:monitor, :daemonize, :deprecated_daemonize, :environment
def initialize
self.cronotab = CRONOTAB
self.logfile = LOGFILE
self.piddir = PIDDIR
self.process_name = PROCESS_NAME
self.daemonize = false
self.deprecated_daemonize = false
self.monitor = false
self.environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
end
def pidfile=(pidfile)
@pidfile = pidfile
self.process_name = Pathname.new(pidfile).basename(".*").to_s
self.piddir = Pathname.new(pidfile).dirname.to_s
end
def pidfile
@pidfile || (daemonize ? PIDFILE : nil)
@pidfile || (deprecated_daemonize ? PIDFILE : nil)
end
end
end