process_bot 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 074d3e8a15a3340496bf231b14a3a8ca664bd8c96c22372ee9bf2251740e8eda
4
- data.tar.gz: 2696dbf343af1d30ca5b4c34b14f69c6278e4d441728b8454943426fe3872112
3
+ metadata.gz: 7faeef8de7bcedd0fb66cc0fcf161de87d94ee3d4e9cceda30086afc12fc09fb
4
+ data.tar.gz: 79370a6f54b1f58ee5df361bdf99637e206310d126bbd9da2a8bbeae509561bb
5
5
  SHA512:
6
- metadata.gz: 2c3d186e16d47a402c01d2e8b1468f814185662a397785cc4ced9f9cacd379b32dc67cf76f12e32d732184e91a361619f773163b1a701baada52f62d6c952291
7
- data.tar.gz: 8763c67b5f30f9fef7f71f739802560b500f23b158b5d8d34cff49c9077f6cfcc06ab24d03c74a4e776aa3c13a0a27fbb4d576fa4a8a8262cc701a1f92c2b893
6
+ metadata.gz: 01ab0ae7b02f813fd00313750924b3162167506cc546b49c6d03dc38fd702b3a5d1082aa45cdc7267800575acdb517381b5243937214319b630ee99d765ee6a2
7
+ data.tar.gz: 0df83d2af7a0180834e6bfb50d3fcd6e9834abb3a60d23a78cd5d80bc5a6c8441ad0f242da3cccb4b8eb4e49fa9ce12d041b87bd69be7d1e729e151f349d1937
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- process_bot (0.1.13)
4
+ process_bot (0.1.14)
5
5
  knjrbfw (>= 0.0.116)
6
6
  pry
7
7
  rake
@@ -43,10 +43,16 @@ class ProcessBot::ControlSocket
43
43
 
44
44
  def run_client_loop
45
45
  Thread.new do
46
- client = server.accept
46
+ loop do
47
+ begin
48
+ client = server.accept
49
+ rescue IOError, Errno::EBADF
50
+ break
51
+ end
47
52
 
48
- Thread.new do
49
- handle_client(client)
53
+ Thread.new do
54
+ handle_client(client)
55
+ end
50
56
  end
51
57
  end
52
58
  end
@@ -67,15 +73,7 @@ class ProcessBot::ControlSocket
67
73
  {}
68
74
  end
69
75
 
70
- if command_type == "graceful_no_wait"
71
- command_type = "graceful"
72
- command_options[:wait_for_gracefully_stopped] = false
73
- end
74
-
75
- logger.logs "Command #{command_type} with options #{command_options}"
76
-
77
- process.__send__(command_type, **command_options)
78
- client.puts(JSON.generate(type: "success"))
76
+ run_command(command_type, command_options, client)
79
77
  rescue => e # rubocop:disable Style/RescueStandardError
80
78
  logger.error e.message
81
79
  logger.error e.backtrace
@@ -100,4 +98,20 @@ class ProcessBot::ControlSocket
100
98
 
101
99
  new_hash
102
100
  end
101
+
102
+ def run_command(command_type, command_options, client)
103
+ command_type, command_options = normalize_command(command_type, command_options)
104
+ logger.logs "Command #{command_type} with options #{command_options}"
105
+
106
+ process.__send__(command_type, **command_options)
107
+ client.puts(JSON.generate(type: "success"))
108
+ end
109
+
110
+ def normalize_command(command_type, command_options)
111
+ return [command_type, command_options] unless command_type == "graceful_no_wait"
112
+
113
+ command_type = "graceful"
114
+ command_options[:wait_for_gracefully_stopped] = false
115
+ [command_type, command_options]
116
+ end
103
117
  end
@@ -1,3 +1,3 @@
1
1
  module ProcessBot
2
- VERSION = "0.1.13".freeze
2
+ VERSION = "0.1.14".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj