mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-07-02 11:43:42 +02:00
src/main.go: switch go routine/main thread order. run spawnTcpServer() in go routine and run event loop in main thread.
This commit is contained in:
parent
6907b3ce75
commit
d4cb1a92f9
2 changed files with 6 additions and 6 deletions
10
src/main.go
10
src/main.go
|
|
@ -80,8 +80,8 @@ func signalEventLoop() {
|
||||||
// subscribe to SIGHUP signal.
|
// subscribe to SIGHUP signal.
|
||||||
signal.Notify(sig_ch, syscall.SIGHUP)
|
signal.Notify(sig_ch, syscall.SIGHUP)
|
||||||
|
|
||||||
// Event loop (runs in a seperate thread)
|
// Event loop
|
||||||
go func() {
|
func() {
|
||||||
for {
|
for {
|
||||||
// Block until we get a signal.
|
// Block until we get a signal.
|
||||||
sig := <- sig_ch
|
sig := <- sig_ch
|
||||||
|
|
@ -149,11 +149,11 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the signal event loop.
|
|
||||||
signalEventLoop()
|
|
||||||
|
|
||||||
addr = argv_listen_addr()
|
addr = argv_listen_addr()
|
||||||
|
|
||||||
// Start listening to TCP Connections
|
// Start listening to TCP Connections
|
||||||
spawnTcpServer(addr);
|
spawnTcpServer(addr);
|
||||||
|
|
||||||
|
// Run the signal event loop.
|
||||||
|
signalEventLoop()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,5 +52,5 @@ func spawnTcpServer(addr string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("TCP Server started", "addr", addr)
|
logger.Info("TCP Server started", "addr", addr)
|
||||||
server.Listen()
|
go server.Listen()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue