Skip to content

add signal handling for build #407

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

peteut
Copy link

@peteut peteut commented Jan 23, 2022

Here's a patch which adds signal handing using exec.CommandContext. Graceful shutdown of the container is achieved using the <executable> stop <name> command.
As the implementation relies on defer, log.Fatal{F} must be be used and fatal is used to allow for defer support.

@peteut peteut force-pushed the add-signal-support branch 2 times, most recently from b432067 to 30c36a9 Compare January 23, 2022 14:08
@peteut peteut force-pushed the add-signal-support branch from 30c36a9 to bf3e7f1 Compare January 23, 2022 14:09
Copy link
Contributor

@stapelberg stapelberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR!

func main() {
defer func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using a custom fatal function, can you please refactor the code such that it returns an error from a new function that is called from main()?

cancel()
log.Println("Stopping ...")
}()
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use signal.NotifyContext instead please

rand.Seed(time.Now().UnixNano())
randBytes := make([]byte, 4)
rand.Read(randBytes)
containerId := "compilekernel-" + hex.EncodeToString(randBytes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put “gokrazy” in the name here, to make it a little more clear to users where the container came from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants