mirror of https://github.com/status-im/go-waku.git
Add: waitgroup for logger to wait for RPC server to be mounted, ref issue:- #299
Signed-off-by: Prajjawalk <prajjawalkhandelwal@gmail.com>
This commit is contained in:
parent
f5d55038b6
commit
066185ee86
|
@ -13,6 +13,7 @@ import (
|
|||
"os/signal"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
|
@ -362,12 +363,16 @@ func Execute(options Options) {
|
|||
rpcServer.Start()
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
var restServer *rest.WakuRest
|
||||
if options.RESTServer.Enable {
|
||||
wg.Add(1)
|
||||
restServer = rest.NewWakuRest(wakuNode, options.RESTServer.Address, options.RESTServer.Port, options.RESTServer.Admin, options.RESTServer.Private, options.RESTServer.RelayCacheCapacity, logger)
|
||||
restServer.Start()
|
||||
restServer.Start(&wg)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
logger.Info("Node setup complete")
|
||||
|
||||
// Wait for a SIGINT or SIGTERM signal
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/waku-org/go-waku/waku/v2/node"
|
||||
|
@ -46,7 +47,8 @@ func NewWakuRest(node *node.WakuNode, address string, port int, enableAdmin bool
|
|||
return wrpc
|
||||
}
|
||||
|
||||
func (r *WakuRest) Start() {
|
||||
func (r *WakuRest) Start(wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
go r.relayService.Start()
|
||||
go func() {
|
||||
_ = r.server.ListenAndServe()
|
||||
|
|
Loading…
Reference in New Issue