Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packaging/aleph-vm/etc/systemd/system/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ WorkingDirectory=/opt/aleph-vm
Environment=PYTHONPATH=/opt/aleph-vm/:$PYTHONPATH
ExecStart=/usr/bin/python3 -m aleph.vm.controllers --config=/var/lib/aleph/vm/%i-controller.json
Restart=on-failure
# KillMode=Mixed is used so initially only the Python controller process receives the SIGTERM signal.
# The controller catches it and sends a QEMU command to shut down the Guest VM, allowing it to clean up
# properly and avoid disk corruption.
# After 30s (TimeoutStopSec), if the process is still running, both the controller and subprocesses receive SIGKILL.
KillMode=mixed
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions src/aleph/vm/controllers/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ async def handle_persistent_vm(config: Configuration, execution: MicroVM | QemuV

def callback():
"""Callback for the signal handler to stop the VM and cleanup properly on SIGTERM."""
logger.debug("Received SIGTERM")
loop.create_task(execution.stop())

loop.add_signal_handler(signal.SIGTERM, callback)
Expand Down