forked from Team-Ortix/blgo
32 lines
651 B
Go
32 lines
651 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func main() {
|
|
created, err := createDefaultConfig()
|
|
if err != nil {
|
|
logrus.Fatalf("error while reading config file: %v", err)
|
|
}
|
|
if created {
|
|
logrus.Info("The default config file has been created. Please edit it and re-run the program.")
|
|
return
|
|
}
|
|
|
|
cfg, err := parseConfig()
|
|
if err != nil {
|
|
logrus.Fatalf("error while parsing the config: %v", err)
|
|
}
|
|
|
|
portStr := strconv.Itoa(cfg.Port)
|
|
logrus.Info("Listening on port " + portStr)
|
|
err = http.ListenAndServe(":"+portStr, nil)
|
|
if err != nil {
|
|
logrus.Fatalf("error while listen and serving: %v", err)
|
|
}
|
|
}
|