1
0
forked from MTSR/mapserver
mapserver/main.go

73 lines
1.0 KiB
Go
Raw Normal View History

2019-01-04 10:41:01 +03:00
package main
import (
2019-01-18 15:50:59 +03:00
"fmt"
2019-01-18 10:47:38 +03:00
"mapserver/app"
2019-01-23 15:22:47 +03:00
"mapserver/mapobject"
2019-01-18 10:47:38 +03:00
"mapserver/params"
2019-01-24 09:52:25 +03:00
"mapserver/tilerendererjob"
2019-01-18 15:50:59 +03:00
"mapserver/web"
2019-01-23 11:11:55 +03:00
"runtime"
2019-02-02 18:21:20 +03:00
"github.com/sirupsen/logrus"
2019-01-04 10:41:01 +03:00
)
2019-01-04 13:00:49 +03:00
func main() {
2019-01-18 10:47:38 +03:00
//Parse command line
2019-01-13 18:32:54 +03:00
2019-01-18 11:13:37 +03:00
p := params.Parse()
2019-01-13 18:32:54 +03:00
2019-01-18 16:23:33 +03:00
if p.Debug {
logrus.SetLevel(logrus.DebugLevel)
} else {
logrus.SetLevel(logrus.InfoLevel)
}
2019-01-18 11:13:37 +03:00
if p.Help {
params.PrintHelp()
return
}
2019-01-13 18:32:54 +03:00
2019-01-18 11:13:37 +03:00
if p.Version {
fmt.Print("Mapserver version: ")
2019-01-24 16:08:44 +03:00
fmt.Println(app.Version)
fmt.Print("OS: ")
fmt.Println(runtime.GOOS)
fmt.Print("Architecture: ")
2019-01-23 11:11:55 +03:00
fmt.Println(runtime.GOARCH)
2019-01-18 11:13:37 +03:00
return
}
2019-01-13 18:32:54 +03:00
2019-01-18 11:03:57 +03:00
//parse Config
2019-01-21 12:53:58 +03:00
cfg, err := app.ParseConfig(app.ConfigFile)
2019-01-18 11:03:57 +03:00
if err != nil {
panic(err)
}
2019-01-21 12:53:58 +03:00
//write back config with all values
err = cfg.Save()
if err != nil {
panic(err)
2019-01-18 11:11:13 +03:00
}
2019-02-14 16:51:20 +03:00
//exit after creating the config
if p.CreateConfig {
return
}
2019-01-18 11:11:13 +03:00
//setup app context
2019-02-01 13:26:57 +03:00
ctx := app.Setup(p, cfg)
2019-01-09 10:56:39 +03:00
2019-01-23 15:22:47 +03:00
//Set up mapobject events
mapobject.Setup(ctx)
2019-01-18 10:47:38 +03:00
//run initial rendering
2019-01-24 09:52:25 +03:00
if ctx.Config.EnableRendering {
go tilerendererjob.Job(ctx)
2019-01-18 15:07:01 +03:00
}
2019-01-18 11:30:51 +03:00
//Start http server
web.Serve(ctx)
2019-01-04 13:00:49 +03:00
}