Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ws-daemon/cmd/root.go
2498 views
1
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package cmd
6
7
import (
8
"fmt"
9
"math/rand"
10
"os"
11
"time"
12
13
"github.com/spf13/cobra"
14
15
"github.com/gitpod-io/gitpod/common-go/log"
16
"github.com/gitpod-io/gitpod/common-go/tracing"
17
)
18
19
var (
20
// ServiceName is the name we use for tracing/logging
21
ServiceName = "ws-daemon"
22
// Version of this service - set during build
23
Version = ""
24
)
25
26
var verbose bool
27
var configFile string
28
var jsonLog bool
29
30
var rootCmd = &cobra.Command{
31
Use: "ws-daemond",
32
Short: "Workspace initialization and synchronization daemon",
33
PersistentPreRun: func(cmd *cobra.Command, args []string) {
34
log.Init(ServiceName, Version, jsonLog, verbose)
35
},
36
}
37
38
// Execute runs this main command
39
func Execute() {
40
closer := tracing.Init("ws-daemon")
41
if closer != nil {
42
defer closer.Close()
43
}
44
45
if err := rootCmd.Execute(); err != nil {
46
fmt.Println(err)
47
os.Exit(1)
48
}
49
}
50
51
func init() {
52
rand.Seed(time.Now().UnixNano())
53
54
rootCmd.PersistentFlags().BoolVarP(&jsonLog, "json-log", "j", true, "produce JSON log output on verbose level")
55
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose JSON logging")
56
rootCmd.PersistentFlags().StringVar(&configFile, "config", "", "config file")
57
}
58
59