add socket server
This commit is contained in:
+4
-2
@@ -66,7 +66,7 @@ func start(cmd *cobra.Command, args []string) {
|
|||||||
// `signal.Notify` registers the given channel to
|
// `signal.Notify` registers the given channel to
|
||||||
// receive notifications of the specified signals.
|
// receive notifications of the specified signals.
|
||||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||||
run = true
|
utils.ServerRunning = true
|
||||||
|
|
||||||
// This goroutine executes a blocking receive for
|
// This goroutine executes a blocking receive for
|
||||||
// signals. When it gets one it'll print it out
|
// 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
|
// expected signal (as indicated by the goroutine
|
||||||
// above sending a value on `done`) and then exit.
|
// above sending a value on `done`) and then exit.
|
||||||
fmt.Println("awaiting signal")
|
fmt.Println("awaiting signal")
|
||||||
for run {
|
_ = utils.InitDb(dbFile, dbInit)
|
||||||
|
utils.Listen(socketAddress)
|
||||||
|
for utils.ServerRunning {
|
||||||
if !utils.IsPortOpen() {
|
if !utils.IsPortOpen() {
|
||||||
log.Println("try to open port")
|
log.Println("try to open port")
|
||||||
err := utils.OpenPort(device, baudrate, bytesize)
|
err := utils.OpenPort(device, baudrate, bytesize)
|
||||||
|
|||||||
Reference in New Issue
Block a user