diff options
author | Florian Dold <florian@dold.me> | 2023-08-23 17:04:17 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-08-23 17:04:17 +0200 |
commit | ec3ae6f5e3f89c13664449bbcbfd2be9a1a6edcc (patch) | |
tree | faec722adf5aff7ad2b33349eae52d78b5d60b45 /packages/taler-harness/src/harness/harness.ts | |
parent | 7fbe28e640d81f60b815ba123e30e97bc0747220 (diff) | |
download | wallet-core-ec3ae6f5e3f89c13664449bbcbfd2be9a1a6edcc.tar.xz |
harness: parallelize service startup
Diffstat (limited to 'packages/taler-harness/src/harness/harness.ts')
-rw-r--r-- | packages/taler-harness/src/harness/harness.ts | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/packages/taler-harness/src/harness/harness.ts b/packages/taler-harness/src/harness/harness.ts index 3a12024dc..8f1f3f452 100644 --- a/packages/taler-harness/src/harness/harness.ts +++ b/packages/taler-harness/src/harness/harness.ts @@ -540,7 +540,7 @@ function backoffStart(): number { } function backoffIncrement(n: number): number { - return Math.max(n * 2, 1000); + return Math.min(Math.floor(n * 1.5), 1000); } /** @@ -563,7 +563,7 @@ export async function pingProc( return; } catch (e: any) { logger.warn(`service ${serviceName} not ready:`, e.toString()); - //console.log(e); + logger.info(`waiting ${nextDelay}ms`); await delayMs(nextDelay); nextDelay = backoffIncrement(nextDelay); } @@ -1535,15 +1535,20 @@ export class ExchangeService implements ExchangeServiceInterface { ); } - async start(): Promise<void> { + async start(opts: { skipSetup?: boolean } = {}): Promise<void> { if (this.isRunning()) { throw Error("exchange is already running"); } - await sh( - this.globalState, - "exchange-dbinit", - `taler-exchange-dbinit -c "${this.configFilename}"`, - ); + + const skipSetup = opts.skipSetup ?? false; + + if (!skipSetup) { + await sh( + this.globalState, + "exchange-dbinit", + `taler-exchange-dbinit -c "${this.configFilename}"`, + ); + } this.helperCryptoEddsaProc = this.globalState.spawnService( "taler-exchange-secmod-eddsa", @@ -1574,7 +1579,11 @@ export class ExchangeService implements ExchangeServiceInterface { ); await this.pingUntilAvailable(); - await this.keyup(); + if (!skipSetup) { + await this.keyup(); + } else { + logger.info("skipping keyup"); + } } async pingUntilAvailable(): Promise<void> { @@ -1912,13 +1921,17 @@ export class MerchantService implements MerchantServiceInterface { } } - async start(): Promise<void> { - await runCommand( - this.globalState, - "merchant-dbinit", - "taler-merchant-dbinit", - ["-c", this.configFilename], - ); + async start(opts: { skipSetup?: boolean } = {}): Promise<void> { + const skipSetup = opts.skipSetup ?? false; + + if (!skipSetup) { + await runCommand( + this.globalState, + "merchant-dbinit", + "taler-merchant-dbinit", + ["-c", this.configFilename], + ); + } this.proc = this.globalState.spawnService( "taler-merchant-httpd", @@ -2285,12 +2298,14 @@ export class WalletService { } async pingUntilAvailable(): Promise<void> { + let nextDelay = backoffStart(); while (1) { try { await tryUnixConnect(this.socketPath); } catch (e) { logger.info(`connection attempt failed: ${e}`); - await delayMs(200); + await delayMs(nextDelay); + nextDelay = backoffIncrement(nextDelay); continue; } logger.info("connection to wallet-core succeeded"); |