forked from 99designs/aws-vault
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.go
More file actions
42 lines (35 loc) · 729 Bytes
/
proxy.go
File metadata and controls
42 lines (35 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package cli
// nolint:depguard
import (
"os"
"os/signal"
"syscall"
"github.com/99designs/aws-vault/v7/server"
"github.com/alecthomas/kingpin/v2"
)
func ConfigureProxyCommand(app *kingpin.Application) {
stop := false
cmd := app.Command("proxy", "Start a proxy for the ec2 instance role server locally.").
Alias("server").
Hidden()
cmd.Flag("stop", "Stop the proxy").
BoolVar(&stop)
cmd.Action(func(*kingpin.ParseContext) error {
if stop {
server.StopProxy()
return nil
}
handleSigTerm()
return server.StartProxy()
})
}
func handleSigTerm() {
// shutdown
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
server.Shutdown()
os.Exit(1)
}()
}