Skip to content

Commit

Permalink
shutdown after 10 sigints if it gets bad +10
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackerjef committed Sep 24, 2021
1 parent 83511b6 commit 2abea7d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions logviewer2/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,26 @@
SECRET_KEY=GET_SECRET_KEY(config),
MAX_CONTENT_LENGTH=(16 * 1024 * 1024),
FDIR=DOWNLOAD_FONTS(),
ISSHUTDOWN=False
ISSHUTDOWN=False,
SHUTDOWNC=0
)


def keyboardInterruptHandler(s, frame):
if not app.config['ISSHUTDOWN']:
app.config['ISSHUTDOWN'] = True
if app.config.get("FDIR", False):
print("cleaning up Fonts")
print("~~~cleaning up Fonts~~~")
app.config["FDIR"].cleanup()
app.config['SHUTDOWNC'] = +1
os.kill(os.getpid(), signal.SIGTERM)
else:
if app.config['SHUTDOWNC'] >= 10:
print("kill hit 10 times, shutting down - {}/10".format(app.config['SHUTDOWNC']))
os.kill(os.getpid(), signal.SIGKILL)
else:
app.config['SHUTDOWNC'] = +1
print("kill hit {}/10 times - killing".format(app.config['SHUTDOWNC']))


signal.signal(signal.SIGINT, keyboardInterruptHandler)
Expand Down

0 comments on commit 2abea7d

Please sign in to comment.