#510·kraken

fix(cmd): use `context.WithCancel` to handle graceful shudowns

Author: sambhav-jain-16Created Nov 28, 2025Updated Nov 28, 2025
Labelsgood first issuego

Is your feature request related to a problem? Please describe. Currently, every cmd code uses log.Fatal to handle the exit of the program, this is really bad since it calls os.Exit directly and it is very hard to implement a stopper in the cmd.Run function.

Describe the solution you'd like Use context.WithCancel to pass a cancellable context, the underlying functions can call cancel in case of an error that requires the entire program to exit. Then cmd.Run can have a exit handler that can listen to this context to gracefully clean up its resources. This context can also be used by underlying functions.