Exemplo n.º 1
0
func runDaemon(conf caretakerd.Config, args []string) {
	instance, err := caretakerd.NewCaretakerd(conf, sync.NewGroup())
	if err != nil {
		stack.Print(err, os.Stderr, 0)
		os.Exit(1)
	}

	instance.Logger().Log(logger.Debug, caretakerd.DaemonName+" successful loaded. Starting now services...")
	exitCode, _ := instance.Run()
	instance.Logger().Log(logger.Debug, caretakerd.DaemonName+" done.")

	instance.Close()

	os.Exit(int(exitCode))
}
Exemplo n.º 2
0
	"github.com/echocat/caretakerd/app"
	"github.com/echocat/caretakerd/logger"
	"github.com/echocat/caretakerd/sync"
	"io/ioutil"
	"os"
	"path/filepath"
)

var version string
var packageName string

var log, _ = logger.NewLogger(logger.Config{
	Level:    logger.Info,
	Filename: "console",
	Pattern:  "%d{YYYY-MM-DD HH:mm:ss} [%-5.5p] %m%n%P{%m}",
}, "manual", sync.NewGroup())

func panicHandler() {
	if r := recover(); r != nil {
		log.LogProblem(r, logger.Fatal, "There is an unrecoverable problem occured.")
		os.Exit(2)
	}
}

func getSrcRootPath() string {
	if len(os.Args) < 2 || len(os.Args[1]) <= 0 {
		fmt.Fprintf(os.Stderr, "Usage: %v <package> <output>\n", os.Args[0])
		os.Exit(1)
	}
	return os.Args[1]
}