Skip to content
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

Graceful shutdown for runtime #708

Open
emil14 opened this issue Sep 26, 2024 · 1 comment
Open

Graceful shutdown for runtime #708

emil14 opened this issue Sep 26, 2024 · 1 comment
Assignees
Labels

Comments

@emil14
Copy link
Collaborator

emil14 commented Sep 26, 2024

When we click ctrl+c we terminate the neva process without handling it. What we probably should do is to close the context to make sure func-runner is gracefully terminated. It's possible to imagine a situation where some component (e.g. http get) opens a connection and never frees it after ctrl+c (or other termination signals from the OS)

Question is, shouldn't user do these kind of things manually? Why e.g. Go doesn't handle resource freeing automatically?

@emil14 emil14 added the Major label Sep 26, 2024
@emil14 emil14 self-assigned this Sep 26, 2024
@emil14
Copy link
Collaborator Author

emil14 commented Sep 26, 2024

    // graceful shutdown for runtime
    ctx, cancel := context.WithCancel(context.Background())

    sigChan := make(chan os.Signal, 1)
    signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)

    go func() {
        <-sigChan
        cancel()
    }()

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

No branches or pull requests

1 participant