1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Server: Allow disabling NTP time drift check

This commit is contained in:
Laurent Cozic 2021-11-29 18:39:07 +00:00
parent 4fecb083a7
commit dc67eace24
2 changed files with 8 additions and 6 deletions

View File

@ -251,12 +251,14 @@ async function main() {
appLogger().info(`Starting server v${config().appVersion} (${env}) on port ${config().port} and PID ${process.pid}...`);
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.`);
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.`);
}
appLogger().info(`NTP time offset: ${timeDrift}ms`);
}
appLogger().info(`NTP time offset: ${timeDrift}ms`);
appLogger().info('Running in Docker:', runningInDocker());
appLogger().info('Public base URL:', config().baseUrl);
appLogger().info('API base URL:', config().apiBaseUrl);

View File

@ -21,8 +21,8 @@ const defaultEnvValues: EnvVariables = {
// milliseconds is normally not an issue unless many clients are modifying
// the same note at the exact same time. But past a certain limit, it might
// mean the server clock is incorrect and should be fixed, as that could
// result in clients generating many conflicts.
// https://github.com/laurent22/joplin/issues/5738
// result in clients generating many conflicts. Set to 0 to disable the
// check. https://github.com/laurent22/joplin/issues/5738
MAX_TIME_DRIFT: 100,