Comments (11)
Hei @smebberson, great explanation! i think -n
and -eq
can be rewritten into just -ne
:
#!/usr/bin/execlineb -S0
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }
s6-svscanctl -t /var/run/s6/services
WDYT?
from s6-overlay.
@glerchundi, yeah, that works too.
Can you confirm the logic is correct though, in moving away from checking $#
to checking ${1}
on the first line?
from s6-overlay.
hi @smebberson,
if { s6-test $# -ne 0 }
doesn't hurt, is just a sanity check and as far as I know it does nothing because finish
always will be run with parameters.
if { s6-test ${1} -ne 0 }
means two things, your process died abnormally or it was signaled by the supervisor. So in this moment you cannot assure why was ./finish
run.
if { s6-test ${1} -ne 256 }
means that ./finish
was run because process exited.
So in this case, s6-svscanctl
will be called if your process exited abnormally but was not called by the supervisor. That means that your container will be kept running even if you call it with docker stop
. Is that what you really want?
from s6-overlay.
@glerchundi, if s6 was signalled (i.e. docker stop
, or CTRL+C
) wouldn't s6 bring down the container anyway (i.e. after the ./finish
script has run - it won't restart the service)? I didn't think it was the ./finish
scripts responsibility to bring down the container under normal circumstances.
That is why I had if -n { s6-test ${1} -eq 256 }
, so that if the container was signalled, the ./finish
script would exit without actually firing s6-svscanctl
command (think s6 would continue bringing down all containers).
from s6-overlay.
@glerchundi, I should clarify the purpose of the script is to bring down the container if the process non-zero exited (as opposed to restart the service which is normal s6 operation).
If the container was signalled to stop, or CTRL+C, then I assumed s6 would bring down the container regardless of any services particular ./finish
script. Which is why the check for 256 takes place in the script in question - so that it doesn't try to bring down the container twice...
from s6-overlay.
That means that your container will be kept running even if you call it with docker stop. Is that what you really want?
Yep, forget this, you're right.
Just to conclude this, the script would look like this:
#!/usr/bin/execlineb -S1
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }
s6-svscanctl -t /var/run/s6/services
Can you test it for me? I'm going to modify the README accordingly.
from s6-overlay.
@glerchundi, yep, I can confirm that works! Great.
from s6-overlay.
Hi @smebberson @glerchundi - I've updated the readme. Go ahead and close this, or let me know if I'm ok to close it. Thanks!
from s6-overlay.
as @smebberson opened it, the ball is in your court
from s6-overlay.
Sorry guys. This all looks great! Thank you.
from s6-overlay.
This exits the finish script (and thus restarts the service) when the process experience a segmentation fault (e.g. gets terminated by the SIGSEGV
signal). This seems to contradict what the title of the issue is saying: The goal is to bring down the container if the supervised processes crashes... For that particular case, a more involved script is necessary.
It seems the goal of if { s6-test ${1} -ne 256 }
is to avoid the finish
script taking down the service which is in the process of being taken down by the supervisor. The default signal to take down a service is SIGTERM
.
So I came up with the following extension which excludes SIGTERM (15) but makes sure the container exits if the main process exited by any other signal (such as SIGSEGV
, SIGILL
etc.). The second argument passed to the finish script is the signal received by the process.
#!/usr/bin/execlineb -S1
if { s6-test ${1} -ne 0 }
ifelse { s6-test ${1} -ne 256 }
if { s6-test ${2} -ne 15 }
s6-svscanctl -t /var/run/s6/services
}
s6-svscanctl -t /var/run/s6/services
Inspiration from #320 (comment)
from s6-overlay.
Related Issues (20)
- `S6_CMD_WAIT_FOR_SERVICES=1` makes no diference HOT 15
- `/command` not present in PATH HOT 7
- systemd notify service conversion exmaple HOT 4
- s6-notifyoncheck: fatal: s6-supervise not running. HOT 3
- Installing S6 on official php-fpm container shows no log output from S6 HOT 5
- Issue with s6-overlay in Cattr project when deployed on Kubernetes HOT 6
- `UID not set` error HOT 10
- Question: pass args to the underlying service HOT 6
- s6-overlay v3 only sends SIGTERM to `/etc/services.d` after `S6_SERVICES_GRACETIME` HOT 8
- Setting S6_READ_ONLY_ROOT does not copy `/etc` to `/run/s6/etc` HOT 3
- Service is started, but reported as "normally down", seemingly by default HOT 11
- 3.1.6.1 hangs at the very end of shutdown for more than a minute HOT 3
- In some rare occasions s6-overlay hangs at shutdown for undefined amount of time HOT 4
- Using s6-overlay with ECS Exec HOT 8
- How to create something similar like cont-init if this one is deprecated ? HOT 3
- Best practice for redirecting output from app1 to app2 HOT 5
- Problem using S6_STAGE2_HOOK to run shell script HOT 2
- s6-linux-init: warning: parent wrote to fd 3! HOT 9
- How to read ENV variables from a file for the main process (defined in CMD) HOT 4
- Shutdown container during s6-rc startup leads to deadlock HOT 3
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-overlay.