From 0176d252352c6d0df7f5e2e67912b301eeec8195 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 18 Feb 2018 21:16:47 +0000 Subject: [PATCH 1/3] Catch SIGTERM instead of (impossible to capture) SIGKILL, also capture Windows service termination --- yggdrasil.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/yggdrasil.go b/yggdrasil.go index 6211ad78..356e7bce 100644 --- a/yggdrasil.go +++ b/yggdrasil.go @@ -9,6 +9,7 @@ import "io/ioutil" import "net" import "os" import "os/signal" +import "syscall" import "time" import "regexp" @@ -21,7 +22,7 @@ import "golang.org/x/net/ipv6" import . "yggdrasil" -import _ "github.com/kardianos/minwinsvc" +import "github.com/kardianos/minwinsvc" /** * This is a very crude wrapper around src/yggdrasil @@ -306,7 +307,13 @@ func main() { } // Catch interrupt to exit gracefully c := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt, os.Kill) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) + // Create a function to capture the service being stopped on Windows + winTerminate := func() { + c <- os.Interrupt + } + minwinsvc.SetOnExit(winTerminate) + // Wait for the terminate/interrupt signal <-c logger.Println("Stopping...") } From aef62afb1b61238246fdf78345a74bca55832557 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 18 Feb 2018 21:32:55 +0000 Subject: [PATCH 2/3] gofmt -s -w yggdrasil.go --- yggdrasil.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yggdrasil.go b/yggdrasil.go index 356e7bce..5abd6b09 100644 --- a/yggdrasil.go +++ b/yggdrasil.go @@ -310,8 +310,8 @@ func main() { signal.Notify(c, os.Interrupt, syscall.SIGTERM) // Create a function to capture the service being stopped on Windows winTerminate := func() { - c <- os.Interrupt - } + c <- os.Interrupt + } minwinsvc.SetOnExit(winTerminate) // Wait for the terminate/interrupt signal <-c From 4f710ac2dace2b1ad051d77d5f15f803edc1c4b7 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 18 Feb 2018 16:07:27 -0600 Subject: [PATCH 3/3] bash -> sh --- build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build b/build index 39b6ae13..8d34668a 100755 --- a/build +++ b/build @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh export GOPATH=$PWD echo "Downloading..." go get -d -v