Class: JIJI::FxServer
- Inherits:
-
WEBrick::HTTPServer
- Object
- WEBrick::HTTPServer
- JIJI::FxServer
- Defined in:
- lib/jiji/server.rb
Instance Method Summary collapse
-
#initialize(base, param = {}) ⇒ FxServer
constructor
A new instance of FxServer.
Constructor Details
#initialize(base, param = {}) ⇒ FxServer
Returns a new instance of FxServer.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/jiji/server.rb', line 10 def initialize( base, param={} ) registry = JIJI::Registry.new(base, self) registry.server_logger.info "base dir : #{base}" # データ移行 JIJI::Util.log_if_error_and_throw(registry.server_logger) { registry.migrator.migrate } # プラグイン registry.plugin_loader.load conf = registry[:conf] param[:Port] = conf.get([:server,:port], 7000).to_i begin fork{} param[:ServerType] = WEBrick::Daemon rescue Exception end param[:MimeTypes] = WEBrick::HTTPUtils::DefaultMimeTypes.merge({"js"=>"application/javascript"}) param[:Logger] = registry[:server_logger] param[:DocumentRoot] = File.( "#{__FILE__}/../../../html" ) param[:Logger].info( "document root: #{ param[:DocumentRoot] }" ) start_callback_org = param[:StartCallback] param[:StartCallback] = proc { JIJI::Util.log_if_error(registry.server_logger) { registry.process_manager.start [:INT,:TERM].each {|sig| trap(sig){ shutdown } } start_callback_org.call if start_callback_org } } stop_callback_org = param[:StopCallback] param[:StopCallback] = proc { JIJI::Util.log_if_error(registry.server_logger) { begin registry.process_manager.stop ensure begin registry.permitter.close ensure registry.securities_plugin_manager.close end end stop_callback_org.call if stop_callback_org } } super(param) mount("/json", JIJI::JsonServlet, registry) end |