@@ -20,7 +20,6 @@ import (
2020 "fmt"
2121 "io"
2222 "os"
23- "os/signal"
2423 "strconv"
2524 "strings"
2625 "syscall"
@@ -30,7 +29,9 @@ import (
3029 "github.com/mongodb/mongodb-atlas-cli/internal/cli"
3130 "github.com/mongodb/mongodb-atlas-cli/internal/config"
3231 "github.com/mongodb/mongodb-atlas-cli/internal/flag"
32+ "github.com/mongodb/mongodb-atlas-cli/internal/log"
3333 "github.com/mongodb/mongodb-atlas-cli/internal/mongosh"
34+ "github.com/mongodb/mongodb-atlas-cli/internal/sighandle"
3435 "github.com/mongodb/mongodb-atlas-cli/internal/store"
3536 "github.com/mongodb/mongodb-atlas-cli/internal/telemetry"
3637 "github.com/mongodb/mongodb-atlas-cli/internal/usage"
@@ -158,7 +159,7 @@ func (opts *Opts) Run() error {
158159 if publicIP := store .IPAddress (); publicIP != "" {
159160 opts .IPAddresses = []string {publicIP }
160161 } else {
161- _ , _ = fmt . Fprintf ( os . Stderr , quickstartTemplateIPNotFound , cli .ExampleAtlasEntryPoint ())
162+ _ , _ = log . Warningf ( quickstartTemplateIPNotFound , cli .ExampleAtlasEntryPoint ())
162163 }
163164 }
164165
@@ -312,13 +313,13 @@ func askMongoShellAndSetConfig() error {
312313// program if it receives an interrupt from the OS. We then handle this by printing
313314// the dbUsername and dbPassword.
314315func (opts * Opts ) setupCloseHandler () {
315- c := make (chan os.Signal , 1 )
316- signal .Notify (c , os .Interrupt , syscall .SIGTERM )
317- go func () {
318- <- c
316+ sighandle .Notify (func (sig os.Signal ) {
319317 fmt .Printf (quickstartTemplateCloseHandler , opts .ClusterName )
318+ telemetry .FinishTrackingCommand (telemetry.TrackOptions {
319+ Signal : sig .String (),
320+ })
320321 os .Exit (0 )
321- }( )
322+ }, os . Interrupt , syscall . SIGTERM )
322323}
323324
324325func (opts * Opts ) providerAndRegionToConstant () {
@@ -374,7 +375,7 @@ func (opts *Opts) newDefaultValues() (*quickstart, error) {
374375 if publicIP := store .IPAddress (); publicIP != "" {
375376 values .IPAddresses = []string {publicIP }
376377 } else {
377- _ , _ = fmt . Fprintf ( os . Stderr , quickstartTemplateIPNotFound , cli .ExampleAtlasEntryPoint ())
378+ _ , _ = log . Warningf ( quickstartTemplateIPNotFound , cli .ExampleAtlasEntryPoint ())
378379 }
379380 }
380381
0 commit comments