Skip to content

Commit 9ab3425

Browse files
committed
Cleanup for the weekend
1 parent 993a464 commit 9ab3425

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

lib/bots/commands_server/Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
gem "nutella_lib", "~> 0.5.0"

lib/supervisor/supervisor.rb

+8-17
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,20 @@
22

33
require_relative 'supervisor_services_pb'
44

5+
# Defines the gRPC server
56
class SupervisorServer < Supervisor::Service
6-
# say_hello implements the SayHello rpc method.
7+
# start_process implements the StartProcess rpc method.
78
def start_process(start_process_req, _unused_call)
89
puts "Someone requested to start a process!!! #{start_process_req}"
910
res = StartProcessResponse.new(success: true)
1011
puts "Responding with: #{res}"
12+
raise "ALE IS AN ASS"
1113
res
1214
end
1315
end
1416

15-
# Everything that is not an SIGINT (2), SIGTERM (15),
16-
# or a hard SIGKILL (9) (and a SIGSTOP(19) I guess...)
17-
# will trigger a process restart
18-
begin
19-
# Listen for commands over GRPC
20-
# Start and stop processes
21-
# Persist after each operation
22-
s = GRPC::RpcServer.new
23-
s.add_http2_port('0.0.0.0:50051', :this_port_is_insecure)
24-
s.handle(SupervisorServer)
25-
s.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])
26-
rescue SignalException => e
27-
# Legit termination, exit
28-
rescue
29-
# everything else... restart
30-
end
17+
# Runs the gRPC server
18+
s = GRPC::RpcServer.new
19+
s.add_http2_port('0.0.0.0:50051', :this_port_is_insecure)
20+
s.handle(SupervisorServer)
21+
s.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])

0 commit comments

Comments
 (0)