Class: ScriptDangoServer
Instance Method Summary collapse
-
#initialize(config = {}, start_options = {}) ⇒ ScriptDangoServer
constructor
A new instance of ScriptDangoServer.
Constructor Details
#initialize(config = {}, start_options = {}) ⇒ ScriptDangoServer
Returns a new instance of ScriptDangoServer.
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 |
# File 'lib/dango/script/dango_server.rb', line 14 def initialize(config = {}, = {}) # コマンドラインオプションでconfigを上書きする .each do |k, v| k =~ /\-\-(\w+?):(\w+?)$/ key1 = Regexp.last_match(1) key2 = Regexp.last_match(2) value = v.dup value = true if v == 'true' value = false if v == 'false' if key1 && key2 config[key1][key2] = value end end # daemonモードで起動 (nochdir=true) Process.daemon(true) if config['server']['daemon'] # serverファイル名一覧を取得 load_files = [] glob_str = 'dango/server/*.rb' Dir.glob(glob_str) do |srv_file| load_files.push({:file=>srv_file, :mtime=>File.mtime(srv_file)}) end # ファイル名順にソート load_files = load_files.sort_by{|f| f[:file] } load_files.each do |f| load f[:file] end DangoServer.start(config) end |