diff --git a/cmd/cron.go b/cmd/cron.go index 0ca970a..f347566 100644 --- a/cmd/cron.go +++ b/cmd/cron.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "log" "runtime" "code.icod.de/dalu/gomanager/ent" @@ -16,12 +17,19 @@ var cronCmd = &cobra.Command{ Use: "cron", Short: "this command is meant to be ran via cron", RunE: func(cmd *cobra.Command, args []string) error { + log.Println("setting GOMAXPROCS=1") runtime.GOMAXPROCS(1) + log.Println("opening database file") client, err := ent.Open("sqlite3", fmt.Sprintf("file:%s?mode=rwc&cache=private&_fk=1", sqliteFilename)) if err != nil { return fmt.Errorf("failed opening connection to sqlite: %v", err) } - defer client.Close() + defer func(client *ent.Client) { + err := client.Close() + if err != nil { + log.Println("error closing client", err.Error()) + } + }(client) r := runner.NewRunner(client) return r.Run() }, diff --git a/runner/runner.go b/runner/runner.go index 09e2ac9..86be9dc 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -24,14 +24,14 @@ func NewRunner(client *ent.Client) *Runner { func (r *Runner) Run() error { ms, e := r.client.Project.Query().All(context.Background()) if e != nil { - return e + return fmt.Errorf("error querying projects: %s", e) } if len(ms) == 0 { return nil } v, e := getCurrentGoVersion() if e != nil { - return e + return fmt.Errorf("error getting current go version: %s", e) } for _, m := range ms { fv, e := getVersionOfFile(fmt.Sprintf("%s/%s", m.RootPath, m.BinaryPath))