even more verbose errors
This commit is contained in:
parent
2175b22f2a
commit
3643d526a7
10
cmd/cron.go
10
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()
|
||||
},
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user