-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable service from cont-init.d #394
Comments
Now it checks if it should start in the service itself.
It does work, but is there a better way to do this? |
@TECH7Fox, yes, that's one option indeed. Just to better illustrate with the first example:
#!/bin/bash
if [[ -z "${ASTERISK_MAILBOX_ENABLED}" ]]; then
exit 0
fi
echo "Starting Asterisk Mailbox"
exec /usr/local/bin/asterisk-mbox-server --cfg /etc/asterisk/asterisk_mbox.ini -U asterisk I wonder what's the preferred approach, or if there is even a third. |
The first approach is the best one. Testing inside the To prevent that, however, you can tell the supervisor to stop restarting the service. So instead of just s6-svc -O .
exit 0 which is code for "when I exit, do not restart me". |
That's awesome. Thanks for the tip! We are using this, therefore: #!/bin/bash
if [[ -z "${ASTERISK_MAILBOX_ENABLED}" ]]; then
s6-svc -O .
exit 0
fi
echo "Starting Asterisk Mailbox"
exec /usr/local/bin/asterisk-mbox-server --cfg /etc/asterisk/asterisk_mbox.ini -U asterisk Do you still think there would be benefits of using the first approach? |
Conceptually, the first approach is: "this service is not even in the list of supervised services", whereas the In practice, having asterix_mbox in the list of supervised services only means one extra supervisor process, which uses a negligible amount of resources, so it doesn't change anything in a noticeable way. |
All right. Thank you very much. Do you think there is anything that can be improved in s6-overlay like an API for disabling services that can be called from If not, I'm good and this issue can be closed. |
The real, evolutive solution is to convert your services to the s6-rc format. A future version of s6-overlay (don't hold your breath!) will include a way for users to choose exactly what sets of services they want started - but unfortunately that cannot include services declared in |
That makes sense! |
@skarnet I'm just wondering, was this feature implemented? |
I'm not sure what I was thinking about when I wrote this. You can achieve dynamic service sets today, with the current version of s6-overlay: have a |
Sounds good, thanks a lot! |
@skarnet do you think it would be worth implementing a new approach for this problem? I'm thinking of something like: If If Example implementation:
#!/command/with-contenv bash
test "${SSHD_ENABLED}" == true The reason why I propose this over For example, let's say I build a base image that ships some optional services preconfigured through a script as |
If I was building a base image and I wanted to let users preconfigure some services, I would write a generic In other words: there is no need for s6-overlay to do anything, because it is already possible via clever hook crafting. 😉 |
Oh sorry, I should have mentioned that I did exactly as you suggested here: (which can also be a reference for other people interested) But my point was that it sounds generic and useful enough to make it a feature of s6-overlay. No problem if you don't think it's a good idea or needed though. Just a suggestion. :) |
Good on you to have done it, then! 😁 But for s6-overlay, and more generally s6-rc, I think it's more important to guarantee bootability of a container (and so, reproducibility) with a given set of services, and the more dynamism is introduced, the harder it is. Flexibility and reproducibility are directly opposed to each other here, unfortunately, and I'm uncomfortable with moving the cursor more towards flexibility. |
Fair enough. Thanks for always promptly replying btw. 🤝 |
I have two services, but depending on how the container is started (i.e. the environment variables), I don't need the second service.
This is how I'm planning to do as a work around:
/etc/cont-init.d/set_services.sh
:Then, instead of defining the service inside of
/etc/services.d/asterisk_mbox
in the Dockerfile, I define them at/usr/share/asterisk_mbox_service
.But it has some drawbacks, for example this only works if I start the container as root.
Any ideas, suggestions?
Refs TECH7Fox/asterisk-hass-addons#77 (comment)
Refs #86
The text was updated successfully, but these errors were encountered: