Skip to content

Commit

Permalink
handle interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
sukantoraymond committed Jul 15, 2024
1 parent ac8f397 commit a4dcfff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/nodecmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ func createNodes(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
fmt.Printf("obtained image ID %s \n", imageID)
numNodesMetricsMap = numNodesMap
if existingMonitoringInstance == "" {
monitoringHostRegion = maps.Keys(numNodesMap)[0]
Expand Down
13 changes: 13 additions & 0 deletions cmd/nodecmd/wiz.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ package nodecmd

import (
"fmt"
"os"
"os/signal"
"strconv"
"strings"
"sync"
"syscall"
"time"

"github.com/ava-labs/avalanche-cli/pkg/metrics"
Expand Down Expand Up @@ -145,6 +148,16 @@ The node wiz command creates a devnet and deploys, sync and validate a subnet in
}

func wiz(cmd *cobra.Command, args []string) error {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
for sig := range c {
fmt.Printf("Received signal: %s\n", sig)
// Perform cleanup or other necessary tasks
fmt.Println("Cleaning up and exiting...")
os.Exit(0)
}
}()
clusterName := args[0]
subnetName := ""
if len(args) > 1 {
Expand Down
3 changes: 0 additions & 3 deletions pkg/cloud/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,6 @@ func (c *GcpCloud) SetupInstances(
return instances, nil
}

// // Copyright (C) 2022, Ava Labs, Inc. All rights reserved.
// // See the file LICENSE for licensing terms.

func (c *GcpCloud) GetUbuntuImageID() (string, error) {
imageListCall := c.gcpClient.Images.List(constants.GCPDefaultImageProvider).Filter(constants.GCPImageFilter)
imageList, err := imageListCall.Do()
Expand Down

0 comments on commit a4dcfff

Please sign in to comment.