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:
parent
39196fa582
commit
4a1bc075ac
@ -38,8 +38,9 @@ export async function getDeviceTimeDrift(): Promise<number> {
|
|||||||
break;
|
break;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (tryCount >= maxTries) {
|
if (tryCount >= maxTries) {
|
||||||
error.message = `Cannot retrieve the network time: ${error.message}`;
|
const newError = typeof error === 'string' ? new Error(error) : error;
|
||||||
throw error;
|
newError.message = `Cannot retrieve the network time from ${server.domain}:${server.port}: ${newError.message}`;
|
||||||
|
throw newError;
|
||||||
} else {
|
} else {
|
||||||
await time.msleep(tryCount * 1000);
|
await time.msleep(tryCount * 1000);
|
||||||
}
|
}
|
||||||
|
@ -254,9 +254,11 @@ async function main() {
|
|||||||
if (config().maxTimeDrift) {
|
if (config().maxTimeDrift) {
|
||||||
const timeDrift = await getDeviceTimeDrift();
|
const timeDrift = await getDeviceTimeDrift();
|
||||||
if (Math.abs(timeDrift) > config().maxTimeDrift) {
|
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`);
|
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());
|
appLogger().info('Running in Docker:', runningInDocker());
|
||||||
|
Loading…
Reference in New Issue
Block a user