pubapi: extract StartVPNAPIServer and StartUpdateLoop as separate functions

Signed-off-by: Malte Poll <mp@edgeless.systems>
This commit is contained in:
Malte Poll 2022-04-28 10:05:59 +02:00 committed by Malte Poll
parent 77b0237dd5
commit f2b3fc328b
4 changed files with 25 additions and 18 deletions

View file

@ -95,16 +95,9 @@ func (a *API) ActivateAsCoordinator(in *pubproto.ActivateAsCoordinatorRequest, s
}
// run the VPN-API server
if err := a.vpnAPIServer.Listen(net.JoinHostPort(coordPeer.VPNIP, vpnAPIPort)); err != nil {
if err := a.StartVPNAPIServer(coordPeer.VPNIP); err != nil {
return status.Errorf(codes.Internal, "start vpnAPIServer: %v", err)
}
a.wgClose.Add(1)
go func() {
defer a.wgClose.Done()
if err := a.vpnAPIServer.Serve(); err != nil {
panic(err)
}
}()
if err := a.core.SwitchToPersistentStore(); err != nil {
return status.Errorf(codes.Internal, "switch to persistent store: %v", err)
}