Skip to content

shut down supervisord with SIGTERM instead of using supervisorctl#470

Merged
SuperSandro2000 merged 1 commit intomicrovm-nix:mainfrom
mikitsu:properly-shutdown-virtiofsd-service
Feb 17, 2026
Merged

shut down supervisord with SIGTERM instead of using supervisorctl#470
SuperSandro2000 merged 1 commit intomicrovm-nix:mainfrom
mikitsu:properly-shutdown-virtiofsd-service

Conversation

@mikitsu
Copy link

@mikitsu mikitsu commented Feb 13, 2026

supervisord interprets SIGTERM as exit request and will shut down the services. Setting KillMode=mixed ensures that systemd does not kill the virtiofsd+notify processes (supervisord will do that).

This commit also drops the autorestart=true from the virtiofsd instances. Since virtiofsd exits on its own with exit code 0 when the VM exits, we do not want supervisord to restart it only to kill it again when the VM has shut down and systemd shuts this service down. Since the default autorestart is "unexpected", supervisord should still restart virtiofsd after abnormal (non-0) exits.
Next to being useless, I've observed (unfortunately without being able to reliably reporduce) that the restart-and-immediately-kill often leads to the virtiofsd process seemingly ignoring the SIGTERM (probably it if is sent before the execve(2), where the supervisord signal handler is still in place). Hence, supervisord waits for virtiofsd to exit for multiple seconds before timing out and killing it, slowing down the shutdown duration.

Why this change? supervisorctl fails with "connection refused", so that shutting down this service means waiting for systemd to time out. AFAICT from the docs, supervisorctl needs supervisord to be listening on a unix or HTTP socket, which only happens if explicitly configured, which is not the case.

supervisord interprets SIGTERM as exit request and will shut down the services.
Setting KillMode=mixed ensures that systemd does not kill the virtiofsd+notify processes
(supervisord will do that).

This commit also drops the autorestart=true from the virtiofsd instances.
Since virtiofsd exits on its own with exit code 0 when the VM exits,
we do not want supervisord to restart it only to kill it again when the VM
has shut down and systemd shuts this service down.
Since the default autorestart is "unexpected", supervisord should still restart
virtiofsd after abnormal (non-0) exits.
Next to being useless, I've observed (unfortunately without being able to reliably reporduce)
that the restart-and-immediately-kill often leads to the virtiofsd process
seemingly ignoring the SIGTERM (probably it if is sent before the execve(2),
where the supervisord signal handler is still in place).
Hence, supervisord waits for virtiofsd to exit for multiple seconds
before timing out and killing it, slowing down the shutdown duration.

Why this change? supervisorctl fails with "connection refused",
so that shutting down this service means waiting for systemd to time out.
AFAICT from the docs, supervisorctl needs supervisord to be listening
on a unix or HTTP socket, which only happens if explicitly configured,
which is not the case.
Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this on our installation and did not observe an immediate difference, but that's probably good as we remove quirky stuff.

@SuperSandro2000 SuperSandro2000 merged commit 789c90b into microvm-nix:main Feb 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments