Closed sameersbn closed 9 years ago
hi @sameersbn, what do you want to achieve? have a down service when your container starts? or stop the service after supervision was started?
The former can be achieve putting an empty down
file in your service folder. As stated in s6
documentation:
http://skarnet.org/software/s6/servicedir.html
:
An optional, empty, regular file named down. If such a file exists, the default state of the service is considered down, not up: s6-supervise will not automatically start it until it receives a s6-svc -u command. If no down file exists, the default state of the service is up.
resolved by adding the following to the finish script
SUPERVISED_DIR=/var/run/s6/services
# hack: this is run-once service
# stop the s6-supervise process and ensure that its not started again
s6-svc -x ${SUPERVISED_DIR}/<service>
rm -rf ${SUPERVISED_DIR}/<service>
s6-svscanctl -a ${SUPERVISED_DIR}
Is there any other recommended way of doing this?
In s6-overlay
you can create oneshot services using /etc/cont-init.d
folder, WDYT?
Actually the process I want to run takes a little time to complete which effects the startup time for of the container if started using init scripts. Since services load up asynchronously it is better suited for be to create a run once service. On Sep 21, 2015 10:32 PM, "Gorka Lerchundi Osa" notifications@github.com wrote:
In s6-overlay you can create oneshot services using /etc/cont-init.d folder, WDYT?
— Reply to this email directly or view it on GitHub https://github.com/just-containers/s6-overlay/issues/86#issuecomment-142043611 .
Basically, my container connects to the internet to check if a newer version is available. Since this is a network operation it takes a little time to complete. Adding this to a /etc/cont-init.d
script significantly increases the containers boot time.
Ideally I want to run this check as a service so that it can happen asynchronously while the container services are being started thereby not having any affect to the containers boot time. At the same time once the service has executed, I don't want it to start again.
The services finish
script I specified in https://github.com/just-containers/s6-overlay/issues/86#issuecomment-142031381 allows me to achieve this (i.e. runonce service). Do you see any issues with this solution?
I also took a look at the service down
option. Since this requires me to manually start the service and since when started, it will automatically restart on exit, it does not really solve the issue.
If you just want to create a script which is going to execute once and not anymore, and also don't block the entire supervision tree startup, what about creating a init script with a background process?
Something like this:
#!/usr/bin/execlineb -P
background
{
check-for-updates
}
In broad terms I don't see any problem with your solution, it's just a different approach to achieve the same thing. If you already have your asynchronous mechanism to communicate with other supervised processes this should work as well as yours...
Can you post your complete use-case in order to evaluate which would be the best option? At least the cleanest one?
@glerchundi i had tried running the check-for-updates
in the background as you mentioned but using a bash script and it did not help because of the wait in the boot sequence.
However the sample script that you shared seems to not have the same issue, which means that I can use it and is a better resolution.
Thanks for the help and support.
you're welcome ;)
one small question. is it possible to silence the s6-overlay logs from the stdout while keeping the service logs? i.e. can i get rid of such messages from the container logs on stdout.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-check-for-updates: executing...
[cont-init.d] 01-check-for-updates: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
For now it's not possible, that's why I raised #32 issue to cover this kind needs. You can post your proposal there.
excellent! thanks.
For anyone that is seeing this now, s6-svc -O /var/run/s6/services/<service>
will allow for a one shot service. Simply run this command at the start of your run script in the service directory.
I create a service at /etc/services.d/ and it starts when the container is started. How can I manually stop the service and remove it from the services list so that it is not started again?