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-server: X(cross) Development System server.
27 "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xdsconfig"
28 "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xdsserver"
29 "github.com/Sirupsen/logrus"
30 "github.com/codegangsta/cli"
34 appName = "xds-server"
35 appDescription = "X(cross) Development System Server is a web server that allows to remotely cross build applications."
36 appCopyright = "Copyright (C) 2017-2018 IoT.bzh - Apache-2.0"
37 appUsage = "X(cross) Development System Server"
40 var appAuthors = []cli.Author{
41 cli.Author{Name: "Sebastien Douheret", Email: "sebastien@iot.bzh"},
44 // AppVersion is the version of this application
45 var AppVersion = "?.?.?"
47 // AppSubVersion is the git tag id added to version string
48 // Should be set by compilation -ldflags "-X main.AppSubVersion=xxx"
49 var AppSubVersion = "unknown-dev"
51 // XDS Server application main routine
52 func xdsApp(cliCtx *cli.Context) error {
55 // Create XDS server context
56 ctxSvr := xdsserver.NewXdsServer(cliCtx)
59 ctxSvr.Config, err = xdsconfig.Init(cliCtx, ctxSvr.Log)
61 return cli.NewExitError(err, -2)
64 // Run XDS Server (main loop)
65 errCode, err := ctxSvr.Run()
67 return cli.NewExitError(err, errCode)
73 // Create a new instance of the logger
76 // Create a new App instance
79 app.Description = appDescription
81 app.Version = AppVersion + " (" + AppSubVersion + ")"
82 app.Authors = appAuthors
83 app.Copyright = appCopyright
84 app.Metadata = make(map[string]interface{})
85 app.Metadata["version"] = AppVersion
86 app.Metadata["git-tag"] = AppSubVersion
87 app.Metadata["logger"] = log
89 app.Flags = []cli.Flag{
92 Usage: "JSON config file to use\n\t",
98 Usage: "logging level (supported levels: panic, fatal, error, warn, info, debug)\n\t",
104 Usage: "filename where logs will be redirected (default stdout)\n\t",
105 EnvVar: "LOG_FILENAME",
108 Name: "no-folderconfig, nfc",
109 Usage: fmt.Sprintf("Do not read folder config file (%s)\n\t", xdsconfig.FoldersConfigFilename),
110 EnvVar: "NO_FOLDERCONFIG",
114 // only one action: Web Server