Skip to content

Commit

Permalink
add ctrl+c signal to command
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpalide committed Nov 29, 2023
1 parent 1089ddd commit cc98d8a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/skywire-cli/commands/vpn/vvpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package clivpn

import (
"bytes"
"context"
"encoding/json"
"fmt"
"math/rand"
Expand All @@ -12,10 +13,12 @@ import (
"text/tabwriter"
"time"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/skycoin/skywire-utilities/pkg/buildinfo"
"github.com/skycoin/skywire-utilities/pkg/cmdutil"
"github.com/skycoin/skywire-utilities/pkg/skyenv"
clirpc "github.com/skycoin/skywire/cmd/skywire-cli/commands/rpc"
"github.com/skycoin/skywire/cmd/skywire-cli/internal"
Expand Down Expand Up @@ -80,6 +83,14 @@ var startCmd = &cobra.Command{
}
internal.Catch(cmd.Flags(), rpcClient.StartVPNClient(pubkey))
internal.PrintOutput(cmd.Flags(), nil, "Starting.")
ctx, cancel := cmdutil.SignalContext(context.Background(), &logrus.Logger{})
defer cancel()
go func() {
<-ctx.Done()
cancel()
rpcClient.StopVPNClient("vpn-client") //nolint
os.Exit(1)
}()
startProcess := true
for startProcess {
time.Sleep(time.Second * 1)
Expand Down

0 comments on commit cc98d8a

Please sign in to comment.