Skip to content

Commit

Permalink
chore: coldstarter command
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcStdt committed Aug 31, 2024
1 parent 36eb36b commit 58801b8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cmd/coldstarter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"context"
"fmt"

"github.com/highcard-dev/daemon/internal/core/services"
"github.com/highcard-dev/daemon/internal/utils/logger"
"github.com/spf13/cobra"
"go.uber.org/zap"
)

var ColdstarterCmd = &cobra.Command{
Use: "run",
Short: "Run single command",
Args: cobra.ExactArgs(1),
Long: `This command runs a single command from the scroll file.`,
RunE: func(cmd *cobra.Command, args []string) error {

scrollService, err := services.NewScrollService(cwd)
if err != nil {
return fmt.Errorf("failed to load scroll - %w", err)
}

currentScroll := scrollService.GetCurrent()

logger.Log().Info("Scroll loaded", zap.String("Name", currentScroll.Name), zap.Any("Version", currentScroll.Version), zap.String("AppVersion", currentScroll.AppVersion), zap.Any("Ports", currentScroll.Ports))

coldStarter := services.NewColdStarter(scrollService.GetDir(), currentScroll.GetColdStartPorts())

coldStarter.StartOnce(context.TODO())
logger.Log().Info("Coldstarter finished")
return nil
},
}

func init() {
}
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func init() {
RootCmd.AddCommand(VersionCmd)
RootCmd.AddCommand(ScrollCmd)
RootCmd.AddCommand(PortMonitorCmd)
RootCmd.AddCommand(ColdstarterCmd)

c, _ := os.Getwd()

Expand Down

0 comments on commit 58801b8

Please sign in to comment.