lib/openwfe/engine/engine.rb in openwferu-0.9.10.653 vs lib/openwfe/engine/engine.rb in openwferu-0.9.11
- old
+ new
@@ -39,10 +39,11 @@
# John Mettraux at openwfe.org
# Nicolas Modrzyk at openwfe.org
#
require 'logger'
+require 'fileutils'
require 'openwfe/workitem'
require 'openwfe/rudefinitions'
require 'openwfe/service'
require 'openwfe/util/irb'
@@ -68,16 +69,25 @@
# Builds an OpenWFEru engine.
#
# Accepts an optional initial application_context (containing
# initialization params for services for example).
#
+ # The engine itself uses one param :logger, used to define
+ # where all the log output for OpenWFEru should go.
+ # By default, this output goes to logs/openwferu.log
+ #
def initialize (application_context={})
super(S_ENGINE, application_context)
- $OWFE_LOG = Logger.new("engine.log") unless $OWFE_LOG
+ $OWFE_LOG = application_context[:logger]
+ unless $OWFE_LOG
+ FileUtils.mkdir("logs") unless File.exist?("logs")
+ $OWFE_LOG = Logger.new("logs/openwferu.log")
+ end
+
# build order matters.
#
# especially for the expstorage which 'observes' the expression
# pool and thus needs to be instantiated after it.
@@ -89,12 +99,10 @@
build_expression_pool()
build_expression_storage()
build_participant_map()
- #get_expression_pool.reschedule()
-
linfo { "new() --- engine started --- #{self.object_id}" }
end
#
# Call this method once the participant for a persisted engine
@@ -253,14 +261,14 @@
freq = freq.to_s.strip
result = if Scheduler.is_cron_string(freq)
- get_scheduler.schedule(freq, nil, listener, nil)
+ get_scheduler.schedule(freq, listener)
else
- get_scheduler.schedule_every(freq, listener, nil)
+ get_scheduler.schedule_every(freq, listener)
end
end
linfo { "add_workitem_listener() added '#{name}'" }
@@ -329,9 +337,11 @@
"stop() stopped service '#{service.service_name}' "+
"(#{service.class})"
end
end
end
+
+ linfo { "stop() stopped engine '#{@service_name}'" }
nil
end
#