blue_green_process 0.1.4.2 → 0.1.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 864e404c1e622e26d8689695a3791b4cf6c84709127617a5d778b550cb03527c
4
- data.tar.gz: 002bba05528b78c7be7184c74bbbf0b94418c12d01d3c93cda5883043b6c376b
3
+ metadata.gz: de6dcd9d5d0d1f000d05cecc5a9e71c9aac40785ab9b662ed3f3e355520583b8
4
+ data.tar.gz: 869f46eade0cbc23f0ad787f37c32dc88e00a8887bdb4d8d16761a00725f10d3
5
5
  SHA512:
6
- metadata.gz: 511d89c74a5a24331cb3d4cc3e72aacf92d8eaed3cc2abcfc4e8964949fa2760fb311d3dd265f2ef185a35c53af70042fa2106b0c6297548793a4565fbc2de9b
7
- data.tar.gz: ab4c37316936239229d153bc4c54747cb184319bd04438d16c81100c0dfc8346c27273727b57112cc9f8f764b91ca4daa28fea8f00d848f93774d216fcde9cbb
6
+ metadata.gz: 3f91ae14371f167c9d1b4ca8480a4b8a02c3487daca3a19e0ce299a99d46c56fe47381a6ed30c61399415995865b7f4118aa7ce823ca1bdd60f27b64fc6e6b7a
7
+ data.tar.gz: b3f7831d0b007d35ba40958b7b14e6faac6f2ad67f0d03bacc1f515f37474f0889c7514bc01dd88c30b74be590dcf20597f0395982dee00119f1ef6e603c04c6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [0.1.4.3] - 2024-1-8
2
+ - 処理を停止するときにpidを書いたファイルを削除するようになりました
3
+
1
4
  ## [0.1.4.2] - 2022-12-25
2
5
  * プロセス終了時にDRb.stop_serviceを呼ぶのをやめました
3
6
 
@@ -5,7 +8,7 @@
5
8
  * プロセス終了時にDRb.stop_serviceを呼ぶようにしました
6
9
 
7
10
  ## [0.1.4] - 2022-12-12
8
- * BlueGreenProcess.terminate_workers_immediately を呼び出すことで、シグナル経由で終了できるようになりました
11
+ * BlueGreenProcess.terminate_workers_immediately を呼び出すことで、masterプロセスからシグナル経由でworkerプロセスを終了できるようになりました
9
12
 
10
13
  ## [0.1.3] - 2022-9-5
11
14
  * 単一プロセスでの実行を延長するとGC.startを実行しなくなりました
data/Gemfile CHANGED
@@ -8,4 +8,4 @@ gemspec
8
8
  gem "pry"
9
9
  gem "rake"
10
10
  gem "rspec"
11
- gem "rubocop", "~> 1.21"
11
+ gem "rubocop"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blue_green_process (0.1.4.2)
4
+ blue_green_process (0.1.4.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -12,11 +12,13 @@ GEM
12
12
  json (2.6.2)
13
13
  method_source (1.0.0)
14
14
  parallel (1.22.1)
15
- parser (3.1.2.0)
15
+ parser (3.3.0.2)
16
16
  ast (~> 2.4.1)
17
+ racc
17
18
  pry (0.14.1)
18
19
  coderay (~> 1.1)
19
20
  method_source (~> 1.0)
21
+ racc (1.7.3)
20
22
  rainbow (3.1.1)
21
23
  rake (13.0.6)
22
24
  regexp_parser (2.5.0)
@@ -59,7 +61,4 @@ DEPENDENCIES
59
61
  pry
60
62
  rake
61
63
  rspec
62
- rubocop (~> 1.21)
63
-
64
- BUNDLED WITH
65
- 2.3.15
64
+ rubocop
data/README.md CHANGED
@@ -2,29 +2,6 @@
2
2
 
3
3
  A library that solves GC bottlenecks with multi-process.
4
4
 
5
- ```mermaid
6
- sequenceDiagram
7
- autonumber
8
- loop
9
- Master->>+Blue: be active
10
- Blue->>-Master: response
11
- Master->>+Blue: work
12
- Blue->>-Master: response
13
- Master->>+Blue: be inactive
14
- Blue->>-Master: response
15
- Blue-->>Blue: GC.start
16
- Master->>+Green: be active
17
- Green->>-Master: response
18
- Master->>+Green: work
19
- Green->>-Master: response
20
- Master->>+Green: be inactive
21
- Green->>-Master: response
22
- Green->>Green: GC.start
23
- end
24
-
25
- ```
26
-
27
-
28
5
  ## Installation
29
6
 
30
7
  Install the gem and add to the application's Gemfile by executing:
@@ -115,6 +115,9 @@ module BlueGreenProcess
115
115
  def shutdown
116
116
  @processes.each(&:shutdown)
117
117
  Process.waitall
118
+ ensure
119
+ # 正常終了だとworkerから削除するケースはないんだけど、想定外のエラーが起きた時を考慮してworkerから削除する
120
+ FileUtils.rm_rf(BlueGreenProcess::PID_PATH)
118
121
  end
119
122
 
120
123
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlueGreenProcess
4
- VERSION = "0.1.4.2"
4
+ VERSION = "0.1.4.3"
5
5
  end
@@ -49,7 +49,7 @@ module BlueGreenProcess
49
49
  def wait_response
50
50
  return unless (text = read)
51
51
 
52
- response = JSON.parse(text.strip)
52
+ response = JSON.parse(text.strip.scrub)
53
53
  BlueGreenProcess::SharedVariable.instance.restore(response["data"])
54
54
  case response["c"]
55
55
  when BlueGreenProcess::RESPONSE_OK
@@ -63,7 +63,7 @@ module BlueGreenProcess
63
63
  begin
64
64
  worker_pids = File.read(PID_PATH).split(",").map(&:to_i)
65
65
  rescue Errno::ENOENT
66
- warn("#{PID_PATH}にファイルがありませんでした")
66
+ BlueGreenProcess.logger.warn("[BLUE_GREEN_PROCESS] #{PID_PATH}にファイルがありませんでした")
67
67
  return
68
68
  end
69
69
 
@@ -72,12 +72,10 @@ module BlueGreenProcess
72
72
  rescue Errno::ESRCH => e
73
73
  BlueGreenProcess.logger.warn("[BLUE_GREEN_PROCESS][#{$PROCESS_ID}] workerプロセス(#{worker_pid})の終了に失敗しました。#{e.message}")
74
74
  end
75
-
76
- begin
77
- Process.wait
78
- rescue Errno::ECHILD => e
79
- BlueGreenProcess.logger.warn("[BLUE_GREEN_PROCESS][#{$PROCESS_ID}] Process.wait(#{e.message})に失敗しました")
80
- end
81
- BlueGreenProcess.logger.warn "[BLUE_GREEN_PROCESS][#{$PROCESS_ID}] TERMシグナルを送信しました"
75
+ BlueGreenProcess.logger.warn "[BLUE_GREEN_PROCESS][#{$PROCESS_ID}] workerプロセスへTERMシグナルを送信しました"
76
+ Process.waitall
77
+ BlueGreenProcess.logger.warn "[BLUE_GREEN_PROCESS][#{$PROCESS_ID}] workerプロセスが終了しました"
78
+ ensure
79
+ FileUtils.rm_rf(BlueGreenProcess::PID_PATH)
82
80
  end
83
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blue_green_process
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4.2
4
+ version: 0.1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiikko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-25 00:00:00.000000000 Z
11
+ date: 2024-01-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A library that solves GC bottlenecks with multi-process.
14
14
  email: