8 "github.com/Sirupsen/logrus"
9 "github.com/urfave/cli"
10 "github.com/iotbzh/xds-agent/lib/agent"
11 "github.com/iotbzh/xds-agent/lib/xdsconfig"
16 appDescription = "X(cross) Development System Agent is a web server that allows to remotely cross build applications."
17 appCopyright = "Apache-2.0"
18 appUsage = "X(cross) Development System Agent"
21 var appAuthors = []cli.Author{
22 cli.Author{Name: "Sebastien Douheret", Email: "sebastien@iot.bzh"},
25 // AppVersion is the version of this application
26 var AppVersion = "?.?.?"
28 // AppSubVersion is the git tag id added to version string
29 // Should be set by compilation -ldflags "-X main.AppSubVersion=xxx"
30 var AppSubVersion = "unknown-dev"
32 // xdsAgent main routine
33 func xdsAgent(cliCtx *cli.Context) error {
36 // Create Agent context
37 ctxAgent := agent.NewAgent(cliCtx)
40 ctxAgent.Config, err = xdsconfig.Init(cliCtx, ctxAgent.Log)
42 return cli.NewExitError(err, 2)
45 // Run Agent (main loop)
46 errCode, err := ctxAgent.Run()
48 return cli.NewExitError(err, errCode)
54 // Create a new instance of the logger
57 // Create a new App instance
60 app.Description = appDescription
62 app.Version = AppVersion + " (" + AppSubVersion + ")"
63 app.Authors = appAuthors
64 app.Copyright = appCopyright
65 app.Metadata = make(map[string]interface{})
66 app.Metadata["version"] = AppVersion
67 app.Metadata["git-tag"] = AppSubVersion
68 app.Metadata["logger"] = log
70 app.Flags = []cli.Flag{
73 Usage: "JSON config file to use\n\t",
74 EnvVar: "XDS_CONFIGFILE",
79 Usage: "logging level (supported levels: panic, fatal, error, warn, info, debug)\n\t",
80 EnvVar: "XDS_LOGLEVEL",
85 Usage: "filename where logs will be redirected (default stdout)\n\t",
86 EnvVar: "XDS_LOGFILE",