22
33require_relative 'supervisor_services_pb'
44
5+ # Defines the gRPC server
56class 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
1315end
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