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."
19 appCopyright = "Apache-2.0"
20 appUsage = "X(cross) Development System Server"
23 var appAuthors = []cli.Author{
24 cli.Author{Name: "Sebastien Douheret", Email: "sebastien@iot.bzh"},
27 // AppVersionGitTag is the git tag id added to version string
28 // Should be set by compilation -ldflags "-X main.AppVersionGitTag=xxx"
29 var AppVersionGitTag = "unknown-dev"
31 // Web server main routine
32 func webServer(ctx *cli.Context) error {
35 cfg, err := xdsconfig.Init(ctx)
37 return cli.NewExitError(err, 2)
40 // Create and start Web Server
41 svr := xdsserver.NewServer(cfg)
42 if err = svr.Serve(); err != nil {
44 return cli.NewExitError(err, 3)
47 return cli.NewExitError("Program exited ", 4)
53 // Create a new instance of the logger
56 // Create a new App instance
59 app.Description = appDescription
61 app.Version = appVersion + " (" + AppVersionGitTag + ")"
62 app.Authors = appAuthors
63 app.Copyright = appCopyright
64 app.Metadata = make(map[string]interface{})
65 app.Metadata["version"] = appVersion
66 app.Metadata["git-tag"] = AppVersionGitTag
67 app.Metadata["logger"] = log
69 app.Flags = []cli.Flag{
72 Usage: "JSON config file to use\n\t",
78 Usage: "logging level (supported levels: panic, fatal, error, warn, info, debug)\n\t",
83 // only one action: Web Server
84 app.Action = webServer