Comments (17)
I think what should probably happen is,
bra should use something like
signal.Notify(c, os.Interrupt)
signal.Notify(c, os.Kill)
signal.Notify(c, syscall.SIGTERM)
when the signal is received, it should kill the child process (using sigterm), but wait until it exits.
perhaps with a timeout of 60 seconds after which it can issue a sigkill.
only after the child process exits, should we close its stdout/stderr.
from bra.
Thanks your feedback!
Just to confirm that you are running as bra run
and no sudo
command is involved, right?
from bra.
when the signal is received, it should kill the child process (using sigterm), but wait until it exits.
Here, do you mean send a os.Interrupt
and wait for a timeout, then do send os.Kill
?
from bra.
Just to confirm that you are running as bra run and no sudo command is involved, right?
right.
Here, do you mean send a os.Interrupt and wait for a timeout, then do send os.Kill?
either one of sigint or sigterm should work fine to issue a termination request to the child process. they are very similar.
and yes, if the process doesn't terminate itself within a given timeout duration, then send sigkill, it looks like (*Process) Kill
from the os package does this for you.
from bra.
Thanks for following up!
I got it now, so I'll change bra to send a os.Interrupt
first and give child process a chance to exit itself.
from bra.
Hi @Dieterbe , I've pushed code for graceful shutdown which first sends os.Interrupt
signal and with for timeout(default is 15 seconds but configurable), then send kill signal.
from bra.
weird. i couldn't reproduce it.
killing bra with bra 0.2 now resulted in the child grafana process just keeping running.
after go get -u github.com/Unknwon/bra
, i.e. Bra version 0.3.3.0903 i have the same behavior. child process just keeps running :?
from bra.
child process just keeps running :?
Hi, I've met this issue before, so if your child process handles kill signal itself, bra can't control it, and of course child process captures your ctrl+c and handles it as well.
from bra.
no i sent sigterm (via kill) to bra, bra stopped, i didn't send anything to the child process (though bra should have)
from bra.
no i sent sigterm (via kill) to bra, bra stopped, i didn't send anything to the child process (though bra should have)
Yes, but if your child process handles sigterm, bra still exits as it should and can't do anything to child process anymore.
from bra.
it looks like child process is not getting a signal at all from bra. because if i send it sigterm (kill) or sigint (kill -int), it successfully exits in both cases within the second. when running under bra, i was stracing the child process and also looking at its log output. when i killed bra i couldn't find evidence of the child process receiving a signal from bra.
from bra.
bra does not send sigterm to child process.
But from what I understood and experienced, your sigterm is passed by something in the middle to your child process, and your child process should exit itself.
Not pro on this topic, can't really tell what's in the black box...
But, I can let Bra captures your sigterm and pass it to child process.
from bra.
there is nothing "in the middle". i have bra just run the grafana process, which i monitor.
but I think i see what's wrong. looking at the bra code, i see that it only sends a signal (sigint) when files change, not when bra itself is exiting. gracefulKill
should also be invoked when bra exits.
from bra.
Yeah, that's good idea.
from bra.
Hi @Dieterbe , I've pushed code to master
, please help test!
from bra.
i can confirm using the latest bra, when bra is asked to exit and shuts down, grafana does not suffer sigpipe anymore, it is given the chance to write some stuff to stdout and exit cleanly.
nice! thank you.
from bra.
Thanks your confirmation!
from bra.
Related Issues (20)
- Deprecated action signature used (codegangsta/cli) HOT 1
- Does not compile against current github.com/codegangsta/cli HOT 6
- Dependency error HOT 2
- Passing in CLI arguments with flags
- How can I install bra command in windows10? HOT 1
- https://gopkg.in/fsnotify.v1no longer exist on this url HOT 3
- Run multiple sets of commands at in parallelize HOT 1
- Inject env variables from file HOT 1
- Support symbolic links HOT 6
- How to pass arguments to bra? HOT 2
- Golang/lib/src/github.com/Unknwon/bra/cmd/run.go:204:17: undefined: com.LgetAllSubDirs HOT 1
- Couldn't install the module HOT 6
- Error on install with my latest go version (go version go1.13.4 linux/amd64) HOT 5
- bra does not re-execute 'cmd' if new changes appear while 'cmd' was still executing HOT 1
- doesn't detect changes in subdir? HOT 1
- can't install on apple m1 (arm)
- How to deal with file without extension HOT 3
- [feature reequest] Set environment variable HOT 2
- 求助:sync命令 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 bra.