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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add app-entrypoint command #48

Merged
merged 3 commits into from
Nov 30, 2021
Merged

Add app-entrypoint command #48

merged 3 commits into from
Nov 30, 2021

Conversation

pglass
Copy link

@pglass pglass commented Nov 23, 2021

Changes proposed in this PR:

Add app-entrypoint subcommand, which effectively supports delaying the TERM signal on Task shutdown for a certain amount of time.

How I've tested this PR:

How I expect reviewers to test this PR:

馃憖

Checklist:

  • Tests added
  • CHANGELOG entry added

@pglass pglass marked this pull request as ready for review November 23, 2021 23:52
Copy link
Contributor

@erichaberkorn erichaberkorn left a comment

Choose a reason for hiding this comment

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

This looks great. All of the comments are nits

subcommand/app-entrypoint/command_common.go Outdated Show resolved Hide resolved
subcommand/app-entrypoint/command_unix.go Outdated Show resolved Hide resolved
subcommand/app-entrypoint/command_unix.go Outdated Show resolved Hide resolved
t.Logf("Check the fake app process is still running")
proc, err := os.FindProcess(appPid)
require.NoError(t, err, "Failed to find fake app process")
// A zero-signal lets us check the process is still valid/running.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised there isn't a better way to accomplish this, but this is fantastic

Co-authored-by: Eric Haberkorn <erichaberkorn@gmail.com>
Copy link
Member

@lkysow lkysow left a comment

Choose a reason for hiding this comment

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

This is brilliant work!

return exitCode
}
if c.shutdownDelay > 0 {
c.log.Info(fmt.Sprintf("consul-ecs: received sigterm. waiting %s before terminating application.", c.shutdownDelay))
Copy link
Member

Choose a reason for hiding this comment

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

can we include the datetime here or use hclog? Might be useful in any debugging situaton

Copy link
Author

Choose a reason for hiding this comment

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

This is using hclog, so we get a timestamp:

2021-11-30T10:49:05.150-0600 [INFO]  consul-ecs: received sigterm. waiting 5s before terminating application.

(Also, CloudWatch has its own timestamps)

Copy link
Member

Choose a reason for hiding this comment

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

Ah nice, then can we use k/v logging instead of fmt.Sprintf?

Copy link
Member

Choose a reason for hiding this comment

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

I guess for this log fmt.Sprintf reads better

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.

None yet

3 participants