From 0c4d851492ed76786823b6c9a69dc7b4c2c59f2c Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Sun, 26 Mar 2023 20:52:58 +0200 Subject: [PATCH] unbound: take into account dig resolve status --- src/services.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/services.js b/src/services.js index ce69bd092..33b312ff7 100644 --- a/src/services.js +++ b/src/services.js @@ -38,6 +38,7 @@ const addonConfigs = require('./addonconfigs.js'), constants = require('./constants.js'), crypto = require('crypto'), debug = require('debug')('box:services'), + dig = require('./dig.js'), docker = require('./docker.js'), eventlog = require('./eventlog.js'), fs = require('fs'), @@ -1864,7 +1865,13 @@ async function restartDocker() { async function statusUnbound() { const [error] = await safe(shell.promises.exec('statusUnbound', 'systemctl is-active unbound')); - return { status: error ? exports.SERVICE_STATUS_STOPPED : exports.SERVICE_STATUS_ACTIVE }; + if (error) return { status: exports.SERVICE_STATUS_STOPPED }; + + const [digError, digResult] = await safe(dig.resolve('ipv4.api.cloudron.io', 'A', { server: '127.0.0.1', timeout: 10000 })); + if (!digError && Array.isArray(digResult) && digResult.length !== 0) return { status: exports.SERVICE_STATUS_ACTIVE }; + + debug('statusUnbound: unbound is up, but failed to resolve ipv4.api.cloudron.io', digError, digResult); + return { status: exports.SERVICE_STATUS_STARTING }; } async function restartUnbound() {