Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ServerCmd = &cobra.Command{ Use: "server", Short: "Start the server process", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { if log.GetLevel() < log.InfoLevel { log.SetLevel(log.InfoLevel) } if runAsDaemon { fmt.Println("Starting the Daytona Server daemon...") err := daemon.Start() if err != nil { log.Fatal(err) } c, err := server.GetConfig() if err != nil { log.Fatal(err) } printServerStartedMessage(c) return } c, err := server.GetConfig() if err != nil { log.Fatal(err) } logsDir, err := server.GetWorkspaceLogsDir() if err != nil { log.Fatal(err) } dbPath, err := getDbPath() if err != nil { log.Fatal(err) } dbConnection := db.GetSQLiteConnection(dbPath) apiKeyStore, err := db.NewApiKeyStore(dbConnection) if err != nil { log.Fatal(err) } gitProviderConfigStore, err := db.NewGitProviderConfigStore(dbConnection) if err != nil { log.Fatal(err) } providerTargetStore, err := db.NewProviderTargetStore(dbConnection) if err != nil { log.Fatal(err) } workspaceStore, err := db.NewWorkspaceStore(dbConnection) if err != nil { log.Fatal(err) } headscaleServer := headscale.NewHeadscaleServer(&headscale.HeadscaleServerConfig{ ServerId: c.Id, FrpsDomain: c.Frps.Domain, FrpsProtocol: c.Frps.Protocol, HeadscalePort: c.HeadscalePort, }) err = headscaleServer.Init() if err != nil { log.Fatal(err) } providerTargetService := providertargets.NewProviderTargetService(providertargets.ProviderTargetServiceConfig{ TargetStore: providerTargetStore, }) apiKeyService := apikeys.NewApiKeyService(apikeys.ApiKeyServiceConfig{ ApiKeyStore: apiKeyStore, }) providerManager := manager.NewProviderManager(manager.ProviderManagerConfig{ LogsDir: logsDir, ProviderTargetService: *providerTargetService, ServerApiUrl: util.GetFrpcApiUrl(c.Frps.Protocol, c.Id, c.Frps.Domain), ServerDownloadUrl: getDaytonaScriptUrl(c), ServerUrl: util.GetFrpcServerUrl(c.Frps.Protocol, c.Id, c.Frps.Domain), RegistryUrl: c.RegistryUrl, BaseDir: c.ProvidersDir, }) provisioner := provisioner.NewProvisioner(provisioner.ProvisionerConfig{ ProviderManager: *providerManager, }) workspaceService := workspaces.NewWorkspaceService(workspaces.WorkspaceServiceConfig{ WorkspaceStore: workspaceStore, TargetStore: providerTargetStore, ApiKeyService: *apiKeyService, ServerApiUrl: util.GetFrpcApiUrl(c.Frps.Protocol, c.Id, c.Frps.Domain), ServerUrl: util.GetFrpcServerUrl(c.Frps.Protocol, c.Id, c.Frps.Domain), Provisioner: *provisioner, NewWorkspaceLogger: func(workspaceId string) logger.Logger { return logger.NewWorkspaceLogger(logsDir, workspaceId) }, NewProjectLogger: func(workspaceId, projectName string) logger.Logger { return logger.NewProjectLogger(logsDir, workspaceId, projectName) }, NewWorkspaceLogReader: func(workspaceId string) (io.Reader, error) { return logger.GetWorkspaceLogReader(logsDir, workspaceId) }, }) gitProviderService := gitproviders.NewGitProviderService(gitproviders.GitProviderServiceConfig{ ConfigStore: gitProviderConfigStore, }) server := server.GetInstance(&server.ServerInstanceConfig{ Config: *c, TailscaleServer: headscaleServer, ProviderTargetService: *providerTargetService, ApiKeyService: *apiKeyService, WorkspaceService: *workspaceService, GitProviderService: *gitProviderService, ProviderManager: *providerManager, }) errCh := make(chan error) err = server.Start(errCh) if err != nil { log.Fatal(err) } apiServer := api.NewApiServer(api.ApiServerConfig{ ApiPort: int(c.ApiPort), }) go func() { err := apiServer.Start() if err != nil { log.Fatal(err) } }() go func() { err := <-errCh if err != nil { log.Fatal(err) } }() for i := 0; i < 3; i++ { err = apiServer.HealthCheck() if err != nil { time.Sleep(3 * time.Second) continue } printServerStartedMessage(c) break } if err != nil { log.Fatal(err) } err = setDefaultConfig(server) if err != nil { log.Fatal(err) } err = <-errCh if err != nil { log.Fatal(err) } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.