I am new to pika. I searched online and I didn't find an answer to what I need.
I am using kubernetes and I need to make sure that my service does a proper graceful shutdown. I have a consumer with code like:
def start_consuming(self):
try:
self.channel.start_consuming()
except KeyboardInterrupt:
self.channel.stop_consuming()
except Exception:
logger.critical("unexpected exception")
raise
finally:
self.connection.close()
When I do a keyboard interrupt, in the logs I correctly see the four messages. Also in rabbitmq I see an info closing connection log. However, if I send a SIGTERM to the process (which is what kubernetes does), there are no logs. Then only thing I see is "Terminated". And in the rabbitmq log I see two warnings saying that the connection was unexpectedly closed.
Is this the normal behavior? The only way to implement a graceful shutdown is to register a signal handler?
Thank you!
Best,
Mauricio