summaryrefslogtreecommitdiffstats
path: root/main.go
blob: 40617d1c236fd747e5b491f1f4698d41a19963c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// TODO add Doc
//
package main

import (
	"log"
	"os"

	"github.com/Sirupsen/logrus"
	"github.com/codegangsta/cli"
	"github.com/iotbzh/xds-server/lib/xdsconfig"
	"github.com/iotbzh/xds-server/lib/xdsserver"
)

const (
	appName        = "xds-server"
	appDescription = "X(cross) Development System Server is a web server that allows to remotely cross build applications."
	appCopyright   = "Apache-2.0"
	appUsage       = "X(cross) Development System Server"
)

var appAuthors = []cli.Author{
	cli.Author{Name: "Sebastien Douheret", Email: "sebastien@iot.bzh"},
}

// AppVersion is the version of this application
var AppVersion = "?.?.?"

// AppSubVersion is the git tag id added to version string
// Should be set by compilation -ldflags "-X main.AppSubVersion=xxx"
var AppSubVersion = "unknown-dev"

// Web server main routine
func webServer(ctx *cli.Context) error {

	// Init config
	cfg, err := xdsconfig.Init(ctx)
	if err != nil {
		return cli.NewExitError(err, 2)
	}

	// Create and start Web Server
	svr := xdsserver.NewServer(cfg)
	if err = svr.Serve(); err != nil {
		log.Println(err)
		return cli.NewExitError(err, 3)
	}

	return cli.NewExitError("Program exited ", 4)
}

// main
func main() {

	// Create a new instance of the logger
	log := logrus.New()

	// Create a new App instance
	app := cli.NewApp()
	app.Name = appName
	app.Description = appDescription
	app.Usage = appUsage
	app.Version = AppVersion + " (" + AppSubVersion + ")"
	app.Authors = appAuthors
	app.Copyright = appCopyright
	app.Metadata = make(map[string]interface{})
	app.Metadata["version"] = AppVersion
	app.Metadata["git-tag"] = AppSubVersion
	app.Metadata["logger"] = log

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:   "config, c",
			Usage:  "JSON config file to use\n\t",
			EnvVar: "APP_CONFIG",
		},
		cli.StringFlag{
			Name:   "log, l",
			Value:  "error",
			Usage:  "logging level (supported levels: panic, fatal, error, warn, info, debug)\n\t",
			EnvVar: "LOG_LEVEL",
		},
	}

	// only one action: Web Server
	app.Action = webServer

	app.Run(os.Args)
}
eta-boundary" path="meta-boundary" remote="github" revision="f96f41b2e5beda2b51acb702d082568898b36a68" upstream="rocko"/> <!-- ti vayu / jacinto 6 / DRA7 --> <project name="meta-ti" path="meta-ti" remote="yocto" revision="ed83a43c6a76875ee5f0388b3b60a28f2a373a10" upstream="rocko"/> <!-- iotivity --> <project name="meta-oic" path="meta-oic" remote="yocto" revision="70d5bec59a3b8aabaa4a69f1d8513ff22d86b473" upstream="1.2.1"/> <!-- rpi 2, 3 and 3 B+ --> <project name="meta-raspberrypi" path="meta-raspberrypi" remote="yocto" revision="acfb857227f1216cd64767952f0c25d633df10b8" upstream="rocko"/> <!-- DragonBoard 410c specific things --> <project name="meta-qcom" path="meta-qcom" remote="yocto" revision="7f06e9f1ce105b70a4bbec836626ba534f97f0f8" upstream="rocko"/> <!-- Altera SOCFPGA platform --> <!-- pinned to version from master until branch for morty exists --> <!-- https://github.com/kraj/meta-altera --> <project name="kraj/meta-altera" path="meta-altera" remote="github" revision="094f4c84da21e199134056f41dcf69f92cacdbd9" upstream="rocko"/> <!-- Image Security Analysis FrameWork (isafw) --> <!-- try master or disable --> <project name="01org/meta-security-isafw" path="meta-security-isafw" remote="github" revision="489abdc65cefb566d696c8b218aa0b9b99a350ae" upstream="master"/> <!-- Security layer --> <project name="meta-security" path="meta-security" remote="yocto" revision="8f6969a775fa6afbf553e72ba83e71197780b2d8" upstream="master"/> <!-- SmartDeviceLink layer --> <project name="phongt/meta-sdl" path="meta-sdl" remote="github" revision="60c9fe8a4a9c6ca95f222685f8d6248f16236f2a" upstream="release/4.4.0"/> </manifest>