1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Server: Display NTP server domain and port when there is an error, and display message when NTP check is skipped

This commit is contained in:
Laurent Cozic 2021-12-16 10:53:28 +01:00
parent 39196fa582
commit 4a1bc075ac
2 changed files with 6 additions and 3 deletions

View File

@ -38,8 +38,9 @@ export async function getDeviceTimeDrift(): Promise<number> {
break;
} catch (error) {
if (tryCount >= maxTries) {
error.message = `Cannot retrieve the network time: ${error.message}`;
throw error;
const newError = typeof error === 'string' ? new Error(error) : error;
newError.message = `Cannot retrieve the network time from ${server.domain}:${server.port}: ${newError.message}`;
throw newError;
} else {
await time.msleep(tryCount * 1000);
}

View File

@ -254,9 +254,11 @@ async function main() {
if (config().maxTimeDrift) {
const timeDrift = await getDeviceTimeDrift();
if (Math.abs(timeDrift) > config().maxTimeDrift) {
throw new Error(`The device time drift is ${timeDrift}ms (Max allowed: ${config().maxTimeDrift}ms) - cannot continue as it could cause data loss and conflicts on the sync clients. You may increase env var MAX_TIME_DRIFT to pass the check.`);
throw new Error(`The device time drift is ${timeDrift}ms (Max allowed: ${config().maxTimeDrift}ms) - cannot continue as it could cause data loss and conflicts on the sync clients. You may increase env var MAX_TIME_DRIFT to pass the check, or set to 0 to disabled the check.`);
}
appLogger().info(`NTP time offset: ${timeDrift}ms`);
} else {
appLogger().info('Skipping NTP time check because MAX_TIME_DRIFT is 0.');
}
appLogger().info('Running in Docker:', runningInDocker());