Hi all,
I'm currently trying to add some graceful shutdown logic into my gRPC
server, but it seems that my shutdown handler never gets called:
def handle_sigterm(*_: Any) -> None :
"""Shutdown gracefully."""
done_event = server.stop(30)
done_event.wait(30)
self.stdout.write('Stop complete.')
server = grpc.server(
futures.ThreadPoolExecutor(max_workers = options['max_workers']),
)
add_
server.add_insecure_port(options['address'])
self.stdout.write(f'Starting gRPC server at {options["address"]}...')
server.start()
start_http_server(int(khaleesi_settings['MONITORING']['PORT']))
signal(SIGTERM, handle_sigterm)
self._log_server_state_event(
action = Event.Action.ActionType.START,
result = Event.Action.ResultType.SUCCESS,
details = 'Server started successfully.'
)
server.wait_for_termination()
except Exception as start_exception:
self._log_server_state_event(
action = Event.Action.ActionType.START,
result = Event.Action.ResultType.ERROR,
details = f'Server startup failed. {type(start_exception).__name__}:
{str(start_exception)}'
)
raise start_exception from None
--
You received this message because you are subscribed to the Google Groups
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/d3ccb089-004d-4c80-afb8-d4ae5be95735n%40googlegroups.com.