Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
ignited: catch signals and cleanup socket file
Browse files Browse the repository at this point in the history
  • Loading branch information
chanwit committed Nov 11, 2019
1 parent 4eea805 commit 680ed3c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cmd/ignited/ignited.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,46 @@ package main

import (
"os"
"os/signal"
"path"
"syscall"

log "github.com/sirupsen/logrus"
"github.com/weaveworks/ignite/cmd/ignited/cmd"
"github.com/weaveworks/ignite/pkg/constants"
"github.com/weaveworks/ignite/pkg/providers"
"github.com/weaveworks/ignite/pkg/providers/ignited"
"github.com/weaveworks/ignite/pkg/util"
)

func main() {
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
go func() {
s := <-sigChan
log.Debugf("Signal %q caught", s)
cleanup()

log.Debug("Program terminated normally")
os.Exit(0)
}()

if err := Run(); err != nil {
log.Debugf("Termination with error: %v", err)
os.Exit(1)
}
}

func cleanup() {

var daemonSocket = path.Join(constants.DATA_DIR, constants.DAEMON_SOCKET)

err := os.Remove(daemonSocket)
if err == nil {
log.Debugf("Socket %q removed successfully", daemonSocket)
}
}

// Run runs the main cobra command of this application
func Run() error {
// Ignite needs to run as root for now, see
Expand Down

0 comments on commit 680ed3c

Please sign in to comment.