9 "github.com/Sirupsen/logrus"
10 "github.com/codegangsta/cli"
11 "github.com/iotbzh/xds-server/lib/xdsconfig"
12 "github.com/iotbzh/xds-server/lib/xdsserver"
16 appName = "xds-server"
17 appDescription = "X(cross) Development System Server is a web server that allows to remotely cross build applications."
18 appCopyright = "Apache-2.0"
19 appUsage = "X(cross) Development System Server"
22 var appAuthors = []cli.Author{
23 cli.Author{Name: "Sebastien Douheret", Email: "sebastien@iot.bzh"},
26 // AppVersion is the version of this application
27 var AppVersion = "?.?.?"
29 // AppSubVersion is the git tag id added to version string
30 // Should be set by compilation -ldflags "-X main.AppSubVersion=xxx"
31 var AppSubVersion = "unknown-dev"
33 // Web server main routine
34 func webServer(ctx *cli.Context) error {
37 cfg, err := xdsconfig.Init(ctx)
39 return cli.NewExitError(err, 2)
42 // Create and start Web Server
43 svr := xdsserver.NewServer(cfg)
44 if err = svr.Serve(); err != nil {
46 return cli.NewExitError(err, 3)
49 return cli.NewExitError("Program exited ", 4)
55 // Create a new instance of the logger
58 // Create a new App instance
61 app.Description = appDescription
63 app.Version = AppVersion + " (" + AppSubVersion + ")"
64 app.Authors = appAuthors
65 app.Copyright = appCopyright
66 app.Metadata = make(map[string]interface{})
67 app.Metadata["version"] = AppVersion
68 app.Metadata["git-tag"] = AppSubVersion
69 app.Metadata["logger"] = log
71 app.Flags = []cli.Flag{
74 Usage: "JSON config file to use\n\t",
80 Usage: "logging level (supported levels: panic, fatal, error, warn, info, debug)\n\t",
85 // only one action: Web Server
86 app.Action = webServer