2 * Copyright (C) 2017-2018 "IoT.bzh"
3 * Author Sebastien Douheret <sebastien@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 * xds-agent: X(cross) Development System client running on developer/local host.
26 "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent/lib/agent"
27 "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent/lib/xdsconfig"
28 "github.com/Sirupsen/logrus"
29 "github.com/urfave/cli"
34 appDescription = "X(cross) Development System Agent is a web server that allows to remotely cross build applications."
35 appCopyright = "Copyright (C) 2017-2018 IoT.bzh - Apache-2.0"
36 appUsage = "X(cross) Development System Agent"
39 var appAuthors = []cli.Author{
40 cli.Author{Name: "Sebastien Douheret", Email: "sebastien@iot.bzh"},
43 // AppVersion is the version of this application
44 var AppVersion = "?.?.?"
46 // AppSubVersion is the git tag id added to version string
47 // Should be set by compilation -ldflags "-X main.AppSubVersion=xxx"
48 var AppSubVersion = "unknown-dev"
50 // xdsAgent main routine
51 func xdsAgent(cliCtx *cli.Context) error {
54 // Create Agent context
55 ctxAgent := agent.NewAgent(cliCtx)
58 ctxAgent.Config, err = xdsconfig.Init(cliCtx, ctxAgent.Log)
60 return cli.NewExitError(err, 2)
63 // Run Agent (main loop)
64 errCode, err := ctxAgent.Run()
66 return cli.NewExitError(err, errCode)
72 // Create a new instance of the logger
75 // Create a new App instance
78 app.Description = appDescription
80 app.Version = AppVersion + " (" + AppSubVersion + ")"
81 app.Authors = appAuthors
82 app.Copyright = appCopyright
83 app.Metadata = make(map[string]interface{})
84 app.Metadata["version"] = AppVersion
85 app.Metadata["git-tag"] = AppSubVersion
86 app.Metadata["logger"] = log
88 app.Flags = []cli.Flag{
91 Usage: "JSON config file to use\n\t",
92 EnvVar: "XDS_CONFIGFILE",
97 Usage: "logging level (supported levels: panic, fatal, error, warn, info, debug)\n\t",
98 EnvVar: "XDS_LOGLEVEL",
103 Usage: "filename where logs will be redirected (default stdout)\n\t",
104 EnvVar: "XDS_LOGFILE",
109 app.Action = xdsAgent