// Run starts the daemon. func (dCmd *Daemon) Run() int { conn := db.New() go engine.Run(conn) go server.Run(conn, dCmd.host) cluster.Run(conn) return 0 }
func main() { /* XXX: GRPC spews a lot of uselss log message so we tell to eat its logs. * Once we have more sophistcated logging support, we should enable the log * messages when in debug mode. */ grpclog.SetLogger(l_mod.New(ioutil.Discard, "", 0)) log.SetFormatter(util.Formatter{}) flag.Usage = func() { fmt.Println("Usage: quilt [inspect <stitch> | run <stitch>" + " | stop <namespace> | get <import_path>]" + " [-log-level=<level> | -l=<level>]") fmt.Println("\nWhen provided a stitch, quilt takes responsibility\n" + "for deploying it as specified. Alternatively, quilt may be\n" + "instructed to stop all deployments in a given namespace,\n" + "or the default namespace if none is provided.\n") flag.PrintDefaults() fmt.Println(" Valid logger levels are:\n" + " debug, info, warn, error, fatal or panic.") } var logLevel = flag.String("log-level", "info", "level to set logger to") flag.StringVar(logLevel, "l", "info", "level to set logger to") flag.Parse() level, err := parseLogLevel(*logLevel) if err != nil { fmt.Println(err) usage() } log.SetLevel(level) conn := db.New() if len(flag.Args()) != 2 { usage() } switch flag.Arg(0) { case "run": go configLoop(conn, flag.Arg(1)) case "stop": stop(conn, flag.Arg(1)) case "get": getSpec(flag.Arg(1)) case "inspect": inspect.Main(flag.Args()) return default: usage() } cluster.Run(conn) }