-
Notifications
You must be signed in to change notification settings - Fork 215
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
V3 finish script not executed #477
Comments
|
Thank you for your prompt answer!
Now the only thing left over is that, even though that the service command fails, it reports that the service successfully started. I was thinking that if a service depends on another one and that the dependency is not met, that it wont start. I think somehow I am missing something. Here is the most recent config: ==> s6-rc.d/user/contents.d/myapp <==
==> s6-rc.d/user/contents.d/secondary <==
==> s6-rc.d/myapp/type <==
longrun
==> s6-rc.d/myapp/run <==
#!/command/execlineb -P
#check if can connect to rabbit mq
socat -u /dev/null tcp-connect:localhost:5672
==> s6-rc.d/myapp/finish <==
#!/command/execlineb -S0
#read the failure count
backtick -D0 -E failcnt {
pipeline { s6-svdt /run/service/myapp/ }
awk "BEGIN{cnt=0}{if($3!=0)cnt++}END{print cnt}"
}
# s6-echo "myapp fail count $failcnt"
if -X { test $failcnt -gt 5 }
foreground { redirfd -w 1 /run/s6-linux-init-container-results/exitcode echo 0 }
/run/s6/basedir/bin/halt
==> s6-rc.d/secondary/type <==
oneshot
==> s6-rc.d/secondary/dependencies.d/myapp <==
==> s6-rc.d/secondary/up <==
And here the console output: s6-rc: info: service myapp: starting
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service myapp successfully started
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
2022/09/16 10:05:01 socat[32] E connect(6, AF=2 127.0.0.1:5672, 16): Connection refused
s6-rc: info: service legacy-services successfully started
/ # 2022/09/16 10:05:02 socat[66] E connect(6, AF=2 127.0.0.1:5672, 16): Connection refused
2022/09/16 10:05:03 socat[71] E connect(6, AF=2 127.0.0.1:5672, 16): Connection refused
2022/09/16 10:05:04 socat[76] E connect(6, AF=2 127.0.0.1:5672, 16): Connection refused
2022/09/16 10:05:05 socat[81] E connect(6, AF=2 127.0.0.1:5672, 16): Connection refused
2022/09/16 10:05:06 socat[86] E connect(6, AF=2 127.0.0.1:5672, 16): Connection refused
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service myapp: stopping
s6-rc: info: service myapp successfully stopped
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped |
I have same issue, the |
@scuzhanglei You'll have to provide more context if you want help. I doubt you're having the exact same issue, given what I've outlined above; please open another issue with details of your problem. @okaerin Sorry for not getting back to you sooner. So the thing with longruns is, once they're started and have reached readiness at least once, s6-rc considers that starting the service has been successful; if the service dies later on, it's a temporary error, the supervisor is supposed to restart it. And when the service doesn't define readiness (there's no To prevent that, you should make sure
The Note that all this is a pretty expensive way to check for RabbitMQ readiness. If RabbitMQ is started in this container, then you should write a readiness script for it instead. If it is started in another container, then you should probably have a policy that says this container will not start before RabbitMQ is ready, and have a readiness checker outside of this container. |
thanks for your reply , below is more details. longrun service / # cat /etc/s6-overlay/s6-rc.d/cloud-hypervisor/type
longrun
/ # cat /etc/s6-overlay/s6-rc.d/cloud-hypervisor/run
#!/usr/bin/execlineb -P
cloud-hypervisor --api-socket /var/run/ch.sock
/ # cat /etc/s6-overlay/s6-rc.d/cloud-hypervisor/finish
#!/bin/sh
if test "$1" -eq 256 ; then
e=$((128 + $2))
else
e="$1"
fi
echo "$e" > /run/s6-linux-init-container-results/exitcode
/run/s6/basedir/bin/halt oneshot service / # cat /etc/s6-overlay/s6-rc.d/virt-prerunner/type
oneshot
/ # cat /etc/s6-overlay/s6-rc.d/virt-prerunner/up
none-exists-command
/ # cat /etc/s6-overlay/s6-rc.d/virt-prerunner/down
/run/s6/basedir/bin/halt
/ # cat /etc/s6-overlay/s6-rc.d/virt-prerunner/dependencies.d/cloud-hypervisor log
|
When the
As an aside, do not call |
|
thanks, it works now. |
@skarnet thanks, it works with the readyness notification |
I am trying to setup S6 to check preconditions (e.g. is a port/socket connectable) and if they are not met the container should fail/stop. To do so I would like to define a service, ideally a one shot which retries n times. What I tried so far was setting up a long running service with a finish script using
s6-permafailon
. Somehow that is never triggered. So either this is a bug or it is not quite clear how to setup finish scripts. To reproduce the issue see the Dockerfile:The text was updated successfully, but these errors were encountered: