Skip to content

Commit

Permalink
terminate_workers_immediatelyを実行後にwaitallを使う
Browse files Browse the repository at this point in the history
  • Loading branch information
jiikko committed Jan 8, 2024
1 parent 3b0c3a7 commit 9d15dd5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/blue_green_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def self.terminate_workers_immediately
begin
worker_pids = File.read(PID_PATH).split(",").map(&:to_i)
rescue Errno::ENOENT
warn("#{PID_PATH}にファイルがありませんでした")
BlueGreenProcess.logger.warn("[BLUE_GREEN_PROCESS] #{PID_PATH}にファイルがありませんでした")
return
end

Expand All @@ -72,12 +72,8 @@ def self.terminate_workers_immediately
rescue Errno::ESRCH => e
BlueGreenProcess.logger.warn("[BLUE_GREEN_PROCESS][#{$PROCESS_ID}] workerプロセス(#{worker_pid})の終了に失敗しました。#{e.message}")
end

begin
Process.wait
rescue Errno::ECHILD => e
BlueGreenProcess.logger.warn("[BLUE_GREEN_PROCESS][#{$PROCESS_ID}] Process.wait(#{e.message})に失敗しました")
end
BlueGreenProcess.logger.warn "[BLUE_GREEN_PROCESS][#{$PROCESS_ID}] TERMシグナルを送信しました"
BlueGreenProcess.logger.warn "[BLUE_GREEN_PROCESS][#{$PROCESS_ID}] workerプロセスへTERMシグナルを送信しました"
Process.waitall
BlueGreenProcess.logger.warn "[BLUE_GREEN_PROCESS][#{$PROCESS_ID}] workerプロセスが終了しました"
end
end

0 comments on commit 9d15dd5

Please sign in to comment.