remove HTTP server
This commit is contained in:
28
main.go
28
main.go
@ -32,14 +32,6 @@ func ParseFlags() (string, error) {
|
||||
return configPath, nil
|
||||
}
|
||||
|
||||
// func getIcon(s string) []byte {
|
||||
// b, err := ioutil.ReadFile(s)
|
||||
// if err != nil {
|
||||
// fmt.Print(err)
|
||||
// }
|
||||
// return b
|
||||
// }
|
||||
|
||||
func main() {
|
||||
|
||||
// Generate our config based on the config supplied
|
||||
@ -57,38 +49,36 @@ func main() {
|
||||
|
||||
DeleteDatabase("./flex.sqlite", log)
|
||||
|
||||
// Load country.xml to get all the DXCC
|
||||
// Load country.xml to get all the DXCC number
|
||||
Countries := LoadCountryFile()
|
||||
|
||||
// Database to keep track of all spots
|
||||
fRepo := NewFlexDXDatabase("flex.sqlite")
|
||||
defer fRepo.db.Close()
|
||||
|
||||
// Database connection to Log4OM
|
||||
cRepo := NewLog4OMContactsRepository(cfg.SQLite.SQLitePath)
|
||||
defer cRepo.db.Close()
|
||||
|
||||
TCPServer := NewTCPServer(cfg.TelnetServer.Host, cfg.TelnetServer.Port)
|
||||
TCPClient := NewTCPClient(TCPServer, Countries)
|
||||
FlexClient := NewFlexClient(*fRepo, TCPServer, TCPClient.SpotChanToFlex)
|
||||
HTTPServer := NewHTTPServer(*cRepo, *fRepo, TCPServer, TCPClient.SpotChanToHTTPServer)
|
||||
// HTTPServer := NewHTTPServer(*cRepo, *fRepo, TCPServer, TCPClient.SpotChanToHTTPServer)
|
||||
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
|
||||
|
||||
if Cfg.General.FlexRadioSpot {
|
||||
go FlexClient.StartFlexClient()
|
||||
}
|
||||
|
||||
go FlexClient.StartFlexClient()
|
||||
go TCPClient.StartClient()
|
||||
go TCPServer.StartServer()
|
||||
|
||||
if Cfg.General.HTTPServer {
|
||||
go HTTPServer.StartHTTPServer()
|
||||
}
|
||||
|
||||
// Gracely closing all connextions if signal is received
|
||||
for sig := range sigCh {
|
||||
log.Infof("received signal: %v, shutting down TCP Client.", sig)
|
||||
log.Infof("received signal: %v, shutting down all connections.", sig)
|
||||
|
||||
TCPClient.Close()
|
||||
TCPServer.Conn.Close()
|
||||
FlexClient.Conn.Close()
|
||||
|
||||
if err := fRepo.db.Close(); err != nil {
|
||||
log.Error("failed to close the database connection properly")
|
||||
|
Reference in New Issue
Block a user