extract webrootdir

This commit is contained in:
Martin Geno 2016-02-26 09:33:07 +01:00
parent 16473e25cf
commit 853e54065c
2 changed files with 18 additions and 14 deletions

View File

@ -11,15 +11,17 @@ Also it's will push statistic informations to a influxdb.
## Usage
```
Usage of ./micro-daemon:
-aliases string
path aliases.json file (default "webroot/aliases.json")
-collectInterval int
interval for data collections (default 15)
-h string
-host string
path aliases.json file
-output string
-httpdir string
a implemented static file webserver (default "webroot")
-path-aliases string
path aliases.json file (default "webroot/aliases.json")
-path-nodes string
path nodes.json file (default "webroot/nodes.json")
-p string
-port string
path aliases.json file (default "8080")
-saveInterval int
interval for data saving (default 60)

20
main.go
View File

@ -23,23 +23,25 @@ var (
respondDaemon *respond.Daemon
nodes = models.NewNodes()
aliases = models.NewNodes()
listenAddr string
listenPort string
collectInterval time.Duration
httpDir string
outputNodesFile string
outputAliasesFile string
collectInterval time.Duration
saveInterval time.Duration
listenPort string
listenAddr string
)
func main() {
var collectSeconds, saveSeconds int
flag.StringVar(&outputNodesFile, "output", "webroot/nodes.json", "path nodes.json file")
flag.StringVar(&outputAliasesFile, "aliases", "webroot/aliases.json", "path aliases.json file")
flag.StringVar(&listenPort, "p", "8080", "path aliases.json file")
flag.StringVar(&listenAddr, "h", "", "path aliases.json file")
flag.IntVar(&saveSeconds, "saveInterval", 60, "interval for data saving")
flag.StringVar(&listenAddr, "host", "", "path aliases.json file")
flag.StringVar(&listenPort, "port", "8080", "path aliases.json file")
flag.IntVar(&collectSeconds, "collectInterval", 15, "interval for data collections")
flag.StringVar(&httpDir, "httpdir", "webroot", "a implemented static file webserver")
flag.StringVar(&outputNodesFile, "path-nodes", "webroot/nodes.json", "path nodes.json file")
flag.StringVar(&outputAliasesFile, "path-aliases", "webroot/aliases.json", "path aliases.json file")
flag.IntVar(&saveSeconds, "saveInterval", 60, "interval for data saving")
flag.Parse()
collectInterval = time.Second * time.Duration(collectSeconds)
@ -73,7 +75,7 @@ func main() {
})
go respondDaemon.ListenAndSend(collectInterval)
http.Handle("/", http.FileServer(http.Dir("webroot")))
http.Handle("/", http.FileServer(http.Dir(httpDir)))
//TODO bad
log.Fatal(http.ListenAndServe(net.JoinHostPort(listenAddr, listenPort), nil))