long-long-float
null+****@clear*****
Thu Aug 28 20:09:11 JST 2014
long-long-float 2014-08-28 20:09:11 +0900 (Thu, 28 Aug 2014) New Revision: 2fbf3b69cc6eca79ee24b524b23bd68b9026d276 https://github.com/long-long-float/droonga-engine/commit/2fbf3b69cc6eca79ee24b524b23bd68b9026d276 Merged d6a9242: Merge pull request #17 from long-long-float/introduction-of-configuration-file Message: Introduce configuration file Modified files: droonga-engine.gemspec lib/droonga/command/droonga_engine.rb lib/droonga/path.rb Modified: droonga-engine.gemspec (+1 -0) =================================================================== --- droonga-engine.gemspec 2014-08-28 19:50:51 +0900 (3943eb7) +++ droonga-engine.gemspec 2014-08-28 20:09:11 +0900 (d8358fc) @@ -38,6 +38,7 @@ Gem::Specification.new do |gem| gem.add_dependency "rroonga", ">= 4.0.1" gem.add_dependency "groonga-command-parser" gem.add_dependency "json" + gem.add_dependency "yaml" gem.add_dependency "cool.io" gem.add_dependency "droonga-message-pack-packer", ">= 1.0.1" gem.add_dependency "faraday" Modified: lib/droonga/command/droonga_engine.rb (+13 -1) =================================================================== --- lib/droonga/command/droonga_engine.rb 2014-08-28 19:50:51 +0900 (db900b1) +++ lib/droonga/command/droonga_engine.rb 2014-08-28 20:09:11 +0900 (2686cb8) @@ -17,6 +17,7 @@ require "optparse" require "socket" require "ipaddr" require "fileutils" +require "yaml" require "coolio" require "sigdump" @@ -113,7 +114,9 @@ module Droonga attr_reader :host, :port, :tag, :log_file, :pid_file_path attr_reader :ready_notify_fd def initialize - @host = Address::DEFAULT_HOST + config = load_config + + @host = config["host"] || Address::DEFAULT_HOST @port = Address::DEFAULT_PORT @tag = Address::DEFAULT_TAG @log_file = nil @@ -122,6 +125,15 @@ module Droonga @ready_notify_fd = nil end + def load_config + path = Droonga::Path.config + if File.exist?(path) + YAML.load_file(path) + else + {} + end + end + def engine_name "#{@host}:#{@port}/#{@tag}" end Modified: lib/droonga/path.rb (+4 -0) =================================================================== --- lib/droonga/path.rb 2014-08-28 19:50:51 +0900 (4e7f86f) +++ lib/droonga/path.rb 2014-08-28 20:09:11 +0900 (3829cd8) @@ -50,6 +50,10 @@ module Droonga state + "effective-message.timestamp" end + def config + base + "droonga-engine.yaml" + end + def catalog base_file_name = ENV["DROONGA_CATALOG"] || "catalog.json" Pathname.new(base_file_name).expand_path(base) -------------- next part -------------- HTML����������������������������... 下載