Log something to be able to see what is happening remotely

Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
Guillaume Tardif 2020-10-26 15:06:54 +01:00
parent 18e43b277c
commit b138a3e4f6
2 changed files with 7 additions and 3 deletions

View File

@ -17,7 +17,9 @@
package etchosts
import (
"fmt"
"os"
"strings"
)
// SetHostNames appends hosts aliases for loopback address to etc/host file
@ -28,6 +30,7 @@ func SetHostNames(file string, hosts ...string) error {
}
defer f.Close() //nolint:errcheck
fmt.Println("Setting local hosts for " + strings.Join(hosts, ", "))
for _, host := range hosts {
_, err = f.WriteString("\n127.0.0.1 " + host)
}

View File

@ -18,10 +18,11 @@ package main
import (
"fmt"
"github.com/docker/compose-cli/aci/etchosts"
"os"
"os/signal"
"syscall"
"github.com/docker/compose-cli/aci/etchosts"
)
const hosts = "/etc/hosts"
@ -39,8 +40,8 @@ func main() {
}
// ACI restart policy is currently at container group level, cannot let the sidecar terminate quietly once /etc/hosts has been edited
// Pause forever (until someone explicitely terminates this process ; go is not happy to stop all goroutines otherwise)
exitSignal := make(chan os.Signal)
// Pause forever (until someone explicitly terminates this process ; go is not happy to stop all goroutines otherwise)
exitSignal := make(chan os.Signal, 1)
signal.Notify(exitSignal, syscall.SIGINT, syscall.SIGTERM)
<-exitSignal
}