Skip to content

Commit

Permalink
systemd: use SIGINT to stop lilac-worker
Browse files Browse the repository at this point in the history
and there is no need to kill it when timed out now.
  • Loading branch information
lilydjwg committed Jun 21, 2024
1 parent 65f8ed4 commit 6d02d31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lilac2/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def start_cmd(
'systemd-run', '--pipe', '--quiet', '--user',
'--wait', '--remain-after-exit', '-u', name,
'-p', 'CPUWeight=100', '-p', 'KillMode=process',
'-p', 'KillSignal=INT',
]

if cwd := kwargs.pop('cwd', None):
Expand Down Expand Up @@ -140,9 +141,6 @@ def poll_rusage(name: str, deadline: float) -> tuple[RUsage, bool]:
nsec = int(v)

finally:
if timedout:
logger.debug('killing worker service')
subprocess.run(['systemctl', '--user', 'kill', '--kill-whom=main', '--signal=SIGINT', name])
logger.debug('stopping worker service')
# stop whatever may be running (even from a previous batch)
subprocess.run(['systemctl', '--user', 'stop', '--quiet', name])
Expand Down
6 changes: 6 additions & 0 deletions lilac2/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ def main() -> None:
# mod failed to load
info = load_lilacinfo(Path('.'))
handle_failure(e, repo, info, Path(input['logfile']))
except KeyboardInterrupt:
logger.info('KeyboardInterrupt received')
r = {
'status': 'failed',
'msg': 'KeyboardInterrupt',
}
finally:
# say goodbye to all our children
kill_child_processes()
Expand Down

0 comments on commit 6d02d31

Please sign in to comment.