From 18e43b277c46c7b2d3f0dd9a8289ee7b7f661c7b Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 26 Oct 2020 15:06:30 +0100 Subject: [PATCH] =?UTF-8?q?fmt.Scanln()=20does=20not=20wait=20forever?= =?UTF-8?q?=E2=80=A6=20waiting=20for=20process=20termination=20signal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guillaume Tardif --- aci/etchosts/main/main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/aci/etchosts/main/main.go b/aci/etchosts/main/main.go index cb2b8315c..547d64751 100644 --- a/aci/etchosts/main/main.go +++ b/aci/etchosts/main/main.go @@ -18,9 +18,10 @@ package main import ( "fmt" - "os" - "github.com/docker/compose-cli/aci/etchosts" + "os" + "os/signal" + "syscall" ) const hosts = "/etc/hosts" @@ -38,6 +39,8 @@ func main() { } // ACI restart policy is currently at container group level, cannot let the sidecar terminate quietly once /etc/hosts has been edited - // Pricing is done at the container group level so letting the sidecar container "sleep" should not impact the price for the whole group - fmt.Scanln() // pause + // Pause forever (until someone explicitely terminates this process ; go is not happy to stop all goroutines otherwise) + exitSignal := make(chan os.Signal) + signal.Notify(exitSignal, syscall.SIGINT, syscall.SIGTERM) + <-exitSignal }