Comments (5)
s6 does not provide that functionality, because it is basically impossible to implement without endangering the state machine of the supervisor and the stability of the system. (Obviously, that's something systemd does not care about.) The closest you can get is the down-signal
file that allows you to configure the signal that is sent to your process in order to stop it.
It is a fundamental design flaw in a daemon if it cannot be cleanly stopped by a signal and needs a specific command. It goes against good practice on Unix systems. Fortunately, most daemons that come with a foobar stop
command actually react to signals, and what foobar stop
does is simply look in the process table to find the instance of the foobard
daemon, and send it a signal, often a SIGTERM
. Use of that command is made totally unnecessary with a supervision system such as s6, because the supervisor already knows the pid of the process without having to look in the process table, and you simply have to tell it to send a signal - in which case the regular way of shutting it down, possibly with a custom down-signal
, will work.
But yes, there are a few daemons that do not behave this way, and foobar stop
uses other IPCs, in which case you have to use the daemon-specific command. For those, you need to first use s6-svc -O
to tell the supervisor not to restart the process when it dies, then run your foobar stop
command.
You seem to be using s6-overlay; I'm not sure exactly how the shutdown sequence is coded exactly, but there should be a way for you to invoke specific commands at shutdown time. If it's not the case, the only thing I can say is that a new version of s6-overlay is planned in a few months, and it will address your concern, among others.
from s6.
Thank you for this reply. I had went through all the documentation an expected this response however I figured I'd ask to have reference if anyone had a similar question in the future. The specific use case that I have relates to a game server. The SIGTERM
signal does function and the server shuts down without data corruption however it does not capture the state of the game prior to shutdown. I've written custom tooling/shell script to shut down the server in a way where it saves before exiting.
You are correct that I'm using s6-overlay. The capability to execute code at shutdown does exist but the features in place appear to be after a signal is sent. I.E final is meant to do memory or filesystem cleanup.
Either way this functionality covers an arguably limited use case that can be worked around so I understand the exclusion. Thanks again.
from s6.
If you have access to the game server's upstream, you could suggest them to devote a signal to the "save the game state then exit" action, which is a common thing that administrators would reasonably want to do. I would even argue that this should be the default behaviour for a SIGTERM
, and that the server should have another signal (for instance SIGQUIT
) that means "exit without saving the state".
from s6.
from s6.
s6-svscan
's signal diversion is about the whole supervision tree, whereas OP's question was about a single service. It cannot help here.
from s6.
Related Issues (20)
- compiling s6 using tcc failed HOT 3
- ExecStartPost equivalent functionality in s6 HOT 2
- readiness notification not working HOT 2
- [Question] transition to s6 based init HOT 3
- A few questions HOT 2
- Philosophy on command line built in help `--help` HOT 2
- Failing to build the latest s6 V2.10.0.0 HOT 1
- Failed to build the latest s6 v2.10.0.0 HOT 1
- s6-svscan shows warning messages on arm32v7/alpine container HOT 1
- [feature] Provide already-built (perhaps statically linked) binaries HOT 3
- Broken link to s6-svperms in overview HOT 1
- s6-svc -d and other signals are not affecting service as expected? HOT 3
- Noob here, I have a couple of questions. HOT 1
- adding hostname in s6-socklog lines and date repetition in s6-log HOT 6
- [Feature Request] Add i18n Support HOT 5
- Installation Error HOT 1
- [Question] Disabling service within service itself HOT 5
- s6-log: log retention duration HOT 2
- notifyoncheck does not kill check after localtimeout HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s6.