mirror of
https://github.com/google/gops.git
synced 2025-02-19 19:59:55 +02:00
cleanup socket on shutdown
This commit is contained in:
parent
6f2aecf323
commit
b73016d838
@ -8,11 +8,13 @@ package agent
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"hello/gops/agent/signal"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
gosignal "os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
|
"hello/gops/agent/signal"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -21,7 +23,16 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
// TODO(jbd): cleanup the socket on shutdown.
|
|
||||||
|
c := make(chan os.Signal, 1)
|
||||||
|
gosignal.Notify(c, os.Interrupt)
|
||||||
|
go func() {
|
||||||
|
// cleanup the socket on shutdown.
|
||||||
|
<-c
|
||||||
|
os.Remove(sock)
|
||||||
|
os.Exit(1)
|
||||||
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
buf := make([]byte, 1)
|
buf := make([]byte, 1)
|
||||||
for {
|
for {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user