Navigation Menu

Skip to content

Commit

Permalink
sample cluster: use config file instead of command line
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 5, 2015
1 parent 3c6abd4 commit 9446d3c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions sample/cluster/Rakefile
Expand Up @@ -17,6 +17,7 @@

require "pathname"
require "json"
require "yaml"

base_dir_path = Pathname.new(__FILE__).dirname
top_dir_path = base_dir_path.parent.parent
Expand Down Expand Up @@ -48,14 +49,12 @@ class DroongaEngine
rm_rf(working_dir_path.to_s)
mkdir_p(working_dir_path.to_s)
generate_catalog(node_ids)
generate_config
end

def start
@pid = spawn("droonga-engine",
"--base-dir", working_dir_path.to_s,
"--host", host,
"--port", self.class.port.to_s,
"--pid-file", pid_file_path.to_s)
"--base-dir", working_dir_path.to_s)
end

def stop
Expand All @@ -77,8 +76,8 @@ class DroongaEngine
working_dir_path + "catalog.json"
end

def pid_file_path
working_dir_path + "droonga-engine.pid"
def config_path
working_dir_path + "droonga-engine.yaml"
end

def generate_catalog(node_ids)
Expand All @@ -91,6 +90,19 @@ class DroongaEngine
"--hosts", hosts.join(","),
"--port", self.class.port.to_s)
end

def generate_config
config = {
"host" => host,
"port" => self.class.port,
"log_file" => "droonga-engine.log",
"log_level" => "info",
"pid_file" => "droonga-engine.pid",
}
config_path.open("w") do |file|
file.puts(config.to_yaml)
end
end
end

namespace :droonga do
Expand Down

0 comments on commit 9446d3c

Please sign in to comment.