func daemon(cmd *cobra.Command, args []string) { api := conf.Handler() nethttp.Handle("/", api) if keyPath != "" { config, err := encrypted.NewTokenConfiguration(filepath.Join(keyPath, "server"), filepath.Join(keyPath, "client.pub")) if err != nil { Fail(1, "Unable to load token configuration: %s", err.Error()) } nethttp.Handle("/token/", nethttp.StripPrefix("/token", config.Handler(api))) } if err := systemd.Start(); err != nil { log.Fatal(err) } if err := containers.InitializeData(); err != nil { log.Fatal(err) } if err := Initialize(ForDaemon); err != nil { log.Fatal(err) } conf.Dispatcher.Start() log.Printf("Listening for HTTP on %s ...", listenAddr) log.Fatal(nethttp.ListenAndServe(listenAddr, nil)) }
// TODO: refactor jobs to take systemd and config // as injected dependencies func initRouter() error { if err := config.HasRequiredDirectories(); err != nil { return err } if err := systemd.Start(); err != nil { return err } if err := InitializeServices(); err != nil { return err } return nil }
// All container jobs depend on these invariants. // TODO: refactor jobs to take systemd and config // as injected dependencies func initContainers() error { if err := config.HasRequiredDirectories(); err != nil { return err } if err := systemd.Start(); err != nil { return err } if err := InitializeData(); err != nil { return err } return nil }