tacticalrmm/main.go

47 lines
751 B
Go
Raw Normal View History

2021-01-12 06:32:00 +00:00
package main
2021-03-27 19:21:52 +00:00
// env CGO_ENABLED=0 go build -ldflags "-s -w" -o nats-api
2021-01-16 00:01:31 +00:00
2021-01-12 06:32:00 +00:00
import (
2021-01-12 21:14:43 +00:00
"flag"
2021-01-15 18:21:25 +00:00
"fmt"
2022-06-30 06:37:58 +00:00
"runtime/debug"
2021-01-12 21:14:43 +00:00
2022-05-10 16:27:51 +00:00
"github.com/amidaware/tacticalrmm/natsapi"
2021-11-13 00:45:28 +00:00
"github.com/sirupsen/logrus"
2021-01-12 06:32:00 +00:00
)
2021-11-13 00:45:28 +00:00
var (
2023-04-07 20:24:43 +00:00
version = "3.4.4"
2021-11-13 00:45:28 +00:00
log = logrus.New()
)
2021-01-15 18:21:25 +00:00
2021-01-12 06:32:00 +00:00
func main() {
2021-01-15 18:21:25 +00:00
ver := flag.Bool("version", false, "Prints version")
2021-11-13 00:45:28 +00:00
cfg := flag.String("config", "", "Path to config file")
logLevel := flag.String("log", "INFO", "The log level")
2021-01-12 21:14:43 +00:00
flag.Parse()
2021-01-15 18:21:25 +00:00
if *ver {
2022-06-30 06:37:58 +00:00
2021-01-15 18:21:25 +00:00
fmt.Println(version)
2022-06-30 06:37:58 +00:00
bi, ok := debug.ReadBuildInfo()
if ok {
fmt.Println(bi.String())
}
2021-01-15 18:21:25 +00:00
return
}
2021-11-13 00:45:28 +00:00
setupLogging(logLevel)
api.Svc(log, *cfg)
}
func setupLogging(level *string) {
ll, err := logrus.ParseLevel(*level)
if err != nil {
ll = logrus.InfoLevel
2021-03-27 19:21:52 +00:00
}
2021-11-13 00:45:28 +00:00
log.SetLevel(ll)
2021-01-12 06:32:00 +00:00
}