Sha256: 5257f281e1288c37ba387e70e21d7dee9ead51056614d448046bc3ddccc10283
Contents?: true
Size: 1.58 KB
Versions: 29
Compression:
Stored size: 1.58 KB
Contents
require 'serverengine' require 'flydata-core/logger' module Flydata module Helper module Server include FlydataCore::Logger OVERWRITE_PARAMETERS = { :worker_type => 'thread', :supervisor => true, } def self.run(opts={}) # See ServerEngine documents for details: # https://github.com/frsyuki/serverengine ServerEngine.create(Server, Worker) do ConfigParser.parse_file(opts[:config_path]). merge(opts).merge(OVERWRITE_PARAMETERS) end.run end def initialize super end attr_reader :action_ownership_channel # ServerEngine hook point def reload_config super setup_log_format log_info "reload_config" if @scheduler @scheduler.reload(config[:helper]) end end # ServerEngine hook point def before_run log_debug "before_run" helper_config = config[:helper] @action_ownership_channel = ActionOwnershipChannel.new @scheduler = Scheduler.new(helper_config, self) @scheduler.start end # ServerEngine hook point def after_run log_debug "after_run" @scheduler.shutdown if @scheduler end def custom_log_items super.merge(prefix: '[server]') end def setup_log_format logger.datetime_format = "%Y-%m-%d %H:%M:%S %z " logger.formatter = proc do |severity, datetime, progname, msg| "#{datetime} helper.#{severity.to_s.downcase}: #{msg}\n" end end end end end
Version data entries
29 entries across 29 versions & 1 rubygems