I am writing a python program which I would run using supervisor. The program basically does the following:
if __name__ == "__main__":
while True:
run()
where run function does a simple task of getting something from database (mysqlDB
) and send that in an email.
I want to write the program such that when I use
supervisorctl stop program
the mysql connection should close and a propper log for shutdown is done.
Is there any way I can handle the stop command in my python script.