diff --git a/cmd/start.go b/cmd/start.go index a57af46..5c610e6 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -66,7 +66,7 @@ func start(cmd *cobra.Command, args []string) { // `signal.Notify` registers the given channel to // receive notifications of the specified signals. signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) - run = true + utils.ServerRunning = true // This goroutine executes a blocking receive for // signals. When it gets one it'll print it out @@ -83,7 +83,9 @@ func start(cmd *cobra.Command, args []string) { // expected signal (as indicated by the goroutine // above sending a value on `done`) and then exit. fmt.Println("awaiting signal") - for run { + _ = utils.InitDb(dbFile, dbInit) + utils.Listen(socketAddress) + for utils.ServerRunning { if !utils.IsPortOpen() { log.Println("try to open port") err := utils.OpenPort(device, baudrate, bytesize)