diff --git a/src/server/Server.ts b/src/server/Server.ts index 1cde9d3..7937386 100644 --- a/src/server/Server.ts +++ b/src/server/Server.ts @@ -35,6 +35,7 @@ export default class Server { protected readonly logger: Console; private readonly _serverImpl: GRPCServerImpl; private readonly _server: GRPCServer; + #start = false; constructor(port: string = process.env.appcallback_GRPC_PORT ?? '9999', GRPCServerInstance?: any, @@ -54,9 +55,10 @@ export default class Server { } async start(): Promise { + if (this.#start) return; + this.#start = true; await this._bind(); this._server.start(); - await sleep(250); } async close(): Promise { diff --git a/test/unit/server/GRPCServerImpl.test.ts b/test/unit/server/GRPCServerImpl.test.ts index 6387647..62af2e7 100644 --- a/test/unit/server/GRPCServerImpl.test.ts +++ b/test/unit/server/GRPCServerImpl.test.ts @@ -65,6 +65,8 @@ describe.skip('server/GRPCServerImpl.test.ts', () => { const serverImpl = new CustomGRPCServerImpl(pubsubConfig); server = new Server('9999', serverImpl); await server.start(); + // start multi times should work + await server.start(); }); afterAll(async () => {