Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,12 @@ func PluralExt(i int, noun string, ext string) string {
// Kubernetes for instance sends a SIGTERM before killing a pod.
// You can place your clean shutdown code after this call in the main().
// This assumes there is another go routine doing something (like a server).
// Using this implies there should be another goroutine at least, so you need to put
// back goroutine logging (vs what log.SetDefaultsForClientTools() does) by calling
// this before starting any other goroutine so there is no race condition:
//
// log.Config.GoroutineID = true
func UntilInterrupted() {
// if UntilInterrupted is called, it implies there should be another goroutine at least.
// so we put back that logging (vs what log.SetDefaultsForClientTools() does).
log.Config.GoroutineID = true
// listen for interrupt signal
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
fortio.org/duration v1.0.4
fortio.org/log v1.17.2
fortio.org/log v1.18.0
fortio.org/version v1.0.4
golang.org/x/crypto/x509roots/fallback v0.0.0-20250203165127-fa5273e46196
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fortio.org/duration v1.0.4 h1:TB07ng4UsMZPDRujJRkTJIcNqMTLM283zob10nb9K24=
fortio.org/duration v1.0.4/go.mod h1:RuBVqdcCKRwMmI8WIdVq8kd7ngQPCIe6G7AU0NC0XDw=
fortio.org/log v1.17.2 h1:JPX/ApDXDoGzsNtXw0AJI4ai6tl9wHp4Ch6bVs1OK0Y=
fortio.org/log v1.17.2/go.mod h1:1V7bPfFI7ZVTdtN9DnUCAN0ilEMs5VgKjHIDRO7Mjzk=
fortio.org/log v1.18.0 h1:mB7gg5AWvcyPUQ0dA6CSUGarX/2rEkv0yWZdARfOdEQ=
fortio.org/log v1.18.0/go.mod h1:1V7bPfFI7ZVTdtN9DnUCAN0ilEMs5VgKjHIDRO7Mjzk=
fortio.org/struct2env v0.4.2 h1:Xh7HlS9vf2ZdRvRfmoGIasNDO8t6z36M713utVODRCo=
fortio.org/struct2env v0.4.2/go.mod h1:lENUe70UwA1zDUCX+8AsO663QCFqYaprk5lnPhjD410=
fortio.org/version v1.0.4 h1:FWUMpJ+hVTNc4RhvvOJzb0xesrlRmG/a+D6bjbQ4+5U=
Expand Down
1 change: 1 addition & 0 deletions sampleTool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func main() {
log.Attr("num_args", len(flag.Args())),
log.Attr("args", flag.Args()))
if *doWait {
log.Config.GoroutineID = true // need to do that _before_ starting other goroutines to get correct logging
log.Infof("Waiting for ^C (or kill) to exit")
cli.UntilInterrupted()
log.Infof("Now done...")
Expand Down