Reputation: 3113
When I kill -SIGINT pid
on my Golang service I have a graceful shutdown where I call the profile.Stop
, but before I could call it I got this message: profile: caught interrupt, stopping profiles
I can't even call the profile.Stop because it's triggered sooner, however the grpc listen and couchbase connection shutdowns works properly.
Is there anyway I can override this malfunctioning profile stop?
Upvotes: 2
Views: 613
Reputation: 418077
There is a profile.NoShutdownHook
function which controls whether the profiling package should hook SIGINT, on which to write profiles cleanly.
You may use / pass the above mentioned function as an option to profile.Start()
if you want to disable this behavior:
profile.Start(profile.NoShutdownHook)
Starting and stopping the profiling inside a function is best done via deferred, e.g.:
// disable the automatic shutdown hook.
defer profile.Start(profile.NoShutdownHook).Stop()
If you disable the automatic shutdown hook, make sure you call Stop()
manually in your shutdown handler properly.
Upvotes: 5