GithubHelp home page GithubHelp logo

Comments (17)

Dieterbe avatar Dieterbe commented on May 12, 2024

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.

unknwon avatar unknwon commented on May 12, 2024

Thanks your feedback!

Just to confirm that you are running as bra run and no sudo command is involved, right?

from bra.

unknwon avatar unknwon commented on May 12, 2024

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.

Dieterbe avatar Dieterbe commented on May 12, 2024

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.

unknwon avatar unknwon commented on May 12, 2024

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.

unknwon avatar unknwon commented on May 12, 2024

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.

Dieterbe avatar Dieterbe commented on May 12, 2024

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.

unknwon avatar unknwon commented on May 12, 2024

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.

Dieterbe avatar Dieterbe commented on May 12, 2024

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.

unknwon avatar unknwon commented on May 12, 2024

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.

Dieterbe avatar Dieterbe commented on May 12, 2024

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.

unknwon avatar unknwon commented on May 12, 2024

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.

Dieterbe avatar Dieterbe commented on May 12, 2024

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.

unknwon avatar unknwon commented on May 12, 2024

Yeah, that's good idea.

from bra.

unknwon avatar unknwon commented on May 12, 2024

Hi @Dieterbe , I've pushed code to master, please help test!

from bra.

Dieterbe avatar Dieterbe commented on May 12, 2024

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.

unknwon avatar unknwon commented on May 12, 2024

Thanks your confirmation!

from bra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.