Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ServeCmd = &cobra.Command{ Use: "serve", Short: "Run the server process in the current terminal session", GroupID: util.SERVER_GROUP, Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { if os.Getenv("USER") == "root" { views.RenderInfoMessageBold("Running the server as root is not recommended because\nDaytona will not be able to remap project directory ownership.\nPlease run the server as a non-root user.") } if log.GetLevel() < log.InfoLevel { log.SetLevel(log.InfoLevel) } configDir, err := server.GetConfigDir() if err != nil { return err } c, err := server.GetConfig() if err != nil { return err } telemetryService := posthogservice.NewTelemetryService(posthogservice.PosthogServiceConfig{ ApiKey: internal.PosthogApiKey, Endpoint: internal.PosthogEndpoint, Version: internal.Version, }) apiServer := api.NewApiServer(api.ApiServerConfig{ ApiPort: int(c.ApiPort), TelemetryService: telemetryService, Version: internal.Version, ServerId: c.Id, Frps: c.Frps, }) server, err := GetInstance(c, configDir, internal.Version, telemetryService) if err != nil { return err } buildRunnerConfig, err := build.GetConfig() if err != nil { return err } buildRunner, err := GetBuildRunner(c, buildRunnerConfig, telemetryService) if err != nil { return err } err = buildRunner.Start() if err != nil { return err } apiServerErrChan := make(chan error) go func() { log.Infof("Starting api server on port %d", c.ApiPort) apiServerErrChan <- apiServer.Start() }() headscaleServerStartedChan := make(chan struct{}) headscaleServerErrChan := make(chan error) go func() { log.Info("Starting headscale server...") err := server.TailscaleServer.Start(headscaleServerErrChan) if err != nil { headscaleServerErrChan <- err return } headscaleServerStartedChan <- struct{}{} }() localContainerRegistryErrChan := make(chan error) go func() { if server.LocalContainerRegistry != nil { log.Info("Starting local container registry...") localContainerRegistryErrChan <- server.LocalContainerRegistry.Start() } else { localContainerRegistryErrChan <- registry.RemoveRegistryContainer() } }() select { case <-headscaleServerStartedChan: log.Info("Headscale server started") go func() { headscaleServerErrChan <- server.TailscaleServer.Connect() }() case err := <-headscaleServerErrChan: return err } err = server.Start() if err != nil { return err } err = waitForApiServerToStart(apiServer) if err != nil { return err } err = <-localContainerRegistryErrChan if err != nil { return err } printServerStartedMessage(c, false) err = ensureDefaultProfile(server, c.ApiPort) if err != nil { return err } interruptChannel := make(chan os.Signal, 1) signal.Notify(interruptChannel, os.Interrupt) select { case err := <-apiServerErrChan: return err case err := <-headscaleServerErrChan: return err case <-interruptChannel: log.Info("Shutting down") return server.TailscaleServer.Stop() } }, }
View Source
var ServerCmd = &cobra.Command{ Use: "server", Short: "Start the server process in daemon mode", GroupID: util.SERVER_GROUP, Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { confirmCheck := true if !yesFlag { view.ConfirmPrompt(&confirmCheck) if !confirmCheck { views.RenderInfoMessage("Operation cancelled.") return nil } } if log.GetLevel() < log.InfoLevel { log.SetLevel(log.InfoLevel) } c, err := server.GetConfig() if err != nil { return err } apiServer := api.NewApiServer(api.ApiServerConfig{ ApiPort: int(c.ApiPort), }) views.RenderInfoMessageBold("Starting the Daytona Server daemon...") err = daemon.Start(c.LogFilePath) if err != nil { return err } err = waitForApiServerToStart(apiServer) if err != nil { return err } printServerStartedMessage(c, true) switch runtime.GOOS { case "linux": fmt.Printf("Use `loginctl enable-linger %s` to allow the service to run after logging out.\n", os.Getenv("USER")) } return nil }, }
Functions ¶
func GetBuildRunner ¶ added in v0.26.0
func GetBuildRunner(c *server.Config, buildRunnerConfig *build.Config, telemetryService telemetry.TelemetryService) (*build.BuildRunner, error)
Types ¶
This section is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.