You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.5 KiB
Go

package main
3 years ago
import (
_"net/http"
_ "net/http/pprof"
//"flag"
"log"
"os"
"fmt"
"FRMS/internal/pkg/logging"
"FRMS/internal/pkg/config"
3 years ago
"FRMS/internal/pkg/server"
3 years ago
)
type listener interface {
3 years ago
Start()
}
func NewListener(ch chan error, port int) listener {
return server.NewListener(ch, port)
}
type dbconfig interface {
GetUrl() string
GetOrg() string
GetBucket() string
GetToken() string
}
func ReadConfig() dbconfig {
return config.ReadServerConfig()
}
3 years ago
func main() {
// lets get this bread
// all we need to do is call the reactor coordinator and thats it
// removing os flags in favor of env vars
// go func() {
// fmt.Println(http.ListenAndServe("localhost:6060",nil))
// }()
3 years ago
ch := make(chan error)
// creating listener
var lport int
//var dbport int
if port := os.Getenv("gRPC_PORT"); port == "" {
lport = 2022 // default docker port
}
//if port := os.Getenv("DATABASE_PORT"); port == "" {
//dbport = 8086
//}
//fmt.Printf("DBPORT %d\n", dbport)
conf := ReadConfig()
fmt.Printf("Found %v %v %v %v\n",conf.GetUrl(),conf.GetBucket(),conf.GetOrg(),conf.GetToken())
fmt.Printf("Listening on %v\n", lport)
l := NewListener(ch,lport)
//db := os.Getenv("DATABASE_URL") // database url
go l.Start()
logging.Debug(logging.DStart, "CCO 01 Server started")
err := <-ch // blocking to wait for any errors and keep alive otherwise
if err != nil {
log.Fatal(err)
}
}