Skip to content

Commit

Permalink
Handle SIGTERM, SIGHUP signals
Browse files Browse the repository at this point in the history
Attempt to shutdown gracefully on receiving SIGTERM or SIGHUP from another process. This allows to properly save the conversation history.

Ref. isamert#112
  • Loading branch information
exquo committed Sep 25, 2021
1 parent c01dbf5 commit eb3ab6b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scli
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import pprint
import re
import shlex
import shutil
import signal as signal_ipc
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -4431,6 +4432,9 @@ def main():
atexit.register(proc.kill)
action_request.set_status_line("Initializing signal-cli daemon... ")

for sig in {signal_ipc.SIGHUP, signal_ipc.SIGTERM}:
signal_ipc.signal(sig, lambda signum, frame: action_request.quit())

with BracketedPasteMode():
loop.run()

Expand Down

0 comments on commit eb3ab6b

Please sign in to comment.