-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.go
49 lines (38 loc) · 1.28 KB
/
run.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package cli
import (
"fmt"
"github.com/colonyos/colonies/pkg/client"
"github.com/colonyos/pollinator/pkg/colonies"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(runCmd)
runCmd.Flags().BoolVarP(&Follow, "follow", "f", false, "Follow process")
runCmd.Flags().IntVarP(&Count, "count", "", 100, "Number of messages to fetch")
}
var runCmd = &cobra.Command{
Use: "run",
Short: "Deploy and run project",
Long: "Deploy and run project",
Run: func(cmd *cobra.Command, args []string) {
parseEnv()
if Verbose {
log.SetLevel(log.DebugLevel)
}
client := client.CreateColoniesClient(ColoniesServerHost, ColoniesServerPort, ColoniesInsecure, ColoniesSkipTLSVerify)
funcSpec, proj := SyncAndGenerateFuncSpec(client)
addedProcess, err := client.Submit(funcSpec, PrvKey)
CheckError(err)
url := DashboardURL + "/process?processid=" + addedProcess.ID
link := fmt.Sprintf("\033]8;;%s\a%s\033]8;;\a\n", url, url)
log.WithFields(log.Fields{"ProcessID": addedProcess.ID}).Info("Process submitted")
log.Info("Follow process at " + link)
if Follow {
err = colonies.Follow(client, addedProcess, PrvKey, Count)
CheckError(err)
err = colonies.SyncDir("/result", client, ColonyName, PrvKey, proj, false)
CheckError(err)
}
},
}