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"
|
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 (
|
2022-05-14 23:00:31 +00:00
|
|
|
version = "3.0.5"
|
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 {
|
|
|
|
fmt.Println(version)
|
|
|
|
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
|
|
|
}
|