From d1d145d51b8f2891371632e209a78e17e58a7b84 Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:08:02 +0100 Subject: [PATCH] Delay bind daemon (#1824) * silence bind daemon * add daemon delay --- .../src/bind/ensureBindContainerIpAndRunning.ts | 3 ++- packages/daemons/src/bind/index.ts | 3 ++- packages/migrations/src/index.ts | 17 ++++++++--------- packages/utils/src/asyncFlows.ts | 4 +++- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/daemons/src/bind/ensureBindContainerIpAndRunning.ts b/packages/daemons/src/bind/ensureBindContainerIpAndRunning.ts index 0fa5e37d4..60d3cd942 100644 --- a/packages/daemons/src/bind/ensureBindContainerIpAndRunning.ts +++ b/packages/daemons/src/bind/ensureBindContainerIpAndRunning.ts @@ -62,7 +62,8 @@ export async function ensureBindContainerIpAndRunning(): Promise { .NetworkSettings.Networks[params.DOCKER_PRIVATE_NETWORK_NAME] .IPAddress === params.BIND_IP; if (hasRightIp) { - logs.info(`${params.bindContainerName} container has right IP`); + // logs.info(`${params.bindContainerName} container has right IP`); + return; } else { logs.info(`${params.bindContainerName} container has wrong IP`); await disconnectConflictingContainerAndStartBind(); diff --git a/packages/daemons/src/bind/index.ts b/packages/daemons/src/bind/index.ts index b158079d6..fedcae909 100644 --- a/packages/daemons/src/bind/index.ts +++ b/packages/daemons/src/bind/index.ts @@ -26,6 +26,7 @@ export function startBindDaemon(signal: AbortSignal): void { runAtMostEvery( async () => ensureBindNetworkConfig(), params.BIND_DAEMON_INTERVAL, - signal + signal, + 1000 * 10 // initial delay ); } diff --git a/packages/migrations/src/index.ts b/packages/migrations/src/index.ts index a47f107d3..59493298c 100644 --- a/packages/migrations/src/index.ts +++ b/packages/migrations/src/index.ts @@ -129,15 +129,14 @@ export async function executeMigrations(): Promise { }) ); - await addDappnodePeerToLocalIpfsNode().catch( - (e: { message: any; stack: any }) => - migrationErrors.push({ - migration: "add Dappnode peer to local IPFS node", - coreVersion: "0.2.88", - name: "MIGRATION_ERROR", - message: e.message, - stack: e.stack, - }) + await addDappnodePeerToLocalIpfsNode().catch((e) => + migrationErrors.push({ + migration: "add Dappnode peer to local IPFS node", + coreVersion: "0.2.88", + name: "MIGRATION_ERROR", + message: e.message, + stack: e.stack, + }) ); if (migrationErrors.length > 0) throw migrationErrors; diff --git a/packages/utils/src/asyncFlows.ts b/packages/utils/src/asyncFlows.ts index bb10f3414..fa8929404 100644 --- a/packages/utils/src/asyncFlows.ts +++ b/packages/utils/src/asyncFlows.ts @@ -68,8 +68,10 @@ interface MemoizeDebouncedFunction export async function runAtMostEvery( fn: () => Promise, intervalMs: number, - signal: AbortSignal + signal: AbortSignal, + initialDelayMs?: number ): Promise { + if (initialDelayMs) await sleep(initialDelayMs, signal); runAtMostEveryIntervals(fn, [intervalMs], signal); }