Navigation Menu

Skip to content

Commit

Permalink
Don't run as daemon
Browse files Browse the repository at this point in the history
We can't use 'p' for debug in daemon mode.
  • Loading branch information
kou committed Apr 8, 2014
1 parent 335fab6 commit 0a16b0d
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions lib/wikipedia-search/task.rb
Expand Up @@ -172,9 +172,10 @@ def define_local_droonga_tasks

droonga_generate_catalog(node_ids)

pids = []
begin
node_ids.each do |node_id|
droonga_run_engine(node_id)
pids << droonga_run_engine(node_id)
end
front_node_id = node_ids.first
droonga_wait_engine_ready(front_node_id)
Expand All @@ -184,26 +185,27 @@ def define_local_droonga_tasks
"--report-throughput",
@path.droonga.pages.to_s)
ensure
node_ids.each do |node_id|
droonga_stop_engine(node_id)
pids.each do |pid|
droonga_stop_engine(pid)
end
end
end

desc "Run Droonga cluster."
task :run do
pids = []
begin
node_ids.each do |node_id|
droonga_run_engine(node_id)
pids << droonga_run_engine(node_id)
port = droonga_port(node_id)
puts("127.0.0.1:#{port}/droonga")
end
front_node_id = node_ids.first
droonga_wait_engine_ready(front_node_id)
$stdin.gets
ensure
node_ids.each do |node_id|
droonga_stop_engine(node_id)
pids.each do |pid|
droonga_stop_engine(pid)
end
end
end
Expand Down Expand Up @@ -259,11 +261,9 @@ def droonga_generate_catalog(node_ids)
end

def droonga_run_engine(node_id)
system("fluentd",
"--config", @path.droonga.fluentd_conf(node_id).expand_path.to_s,
"--log", @path.droonga.log(node_id).expand_path.to_s,
"--daemon", @path.droonga.pid(node_id).expand_path.to_s,
:chdir => @path.droonga.working_dir.to_s)
spawn("fluentd",
"--config", @path.droonga.fluentd_conf(node_id).expand_path.to_s,
:chdir => @path.droonga.working_dir.to_s)
end

def droonga_wait_engine_ready(node_id)
Expand All @@ -277,9 +277,8 @@ def droonga_wait_engine_ready(node_id)
end
end

def droonga_stop_engine(node_id)
pid_path = @path.droonga.pid(node_id)
Process.kill(:TERM, Integer(pid_path.read)) if pid_path.exist?
def droonga_stop_engine(pid)
Process.kill(:TERM, pid)
end
end
end

0 comments on commit 0a16b0d

Please sign in to comment.