From 5d5ea6a5c2a5f9eb1bcb1e8090c33c0de804b34a Mon Sep 17 00:00:00 2001 From: azivner Date: Thu, 9 Nov 2017 20:06:33 -0500 Subject: [PATCH] configurable sync timeout --- services/sync.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/services/sync.js b/services/sync.js index ab5b63120..90b01bc7e 100644 --- a/services/sync.js +++ b/services/sync.js @@ -14,7 +14,7 @@ const notes = require('./notes'); const SYNC_SERVER = config['Sync']['syncServerHost']; const isSyncSetup = !!SYNC_SERVER; - +const SYNC_TIMEOUT = config['Sync']['syncServerTimeout'] || 5000; let syncInProgress = false; @@ -30,7 +30,7 @@ async function pullSync(syncContext) { uri: SYNC_SERVER + '/api/sync/changed?lastSyncId=' + lastSyncedPull + "&sourceId=" + SOURCE_ID, jar: syncContext.cookieJar, json: true, - timeout: 5 * 1000 + timeout: SYNC_TIMEOUT }); logSync("Pulled " + syncRows.length + " changes"); @@ -46,7 +46,8 @@ async function pullSync(syncContext) { resp = await rp({ uri: SYNC_SERVER + "/api/sync/" + sync.entity_name + "/" + sync.entity_id, json: true, - jar: syncContext.cookieJar + jar: syncContext.cookieJar, + timeout: SYNC_TIMEOUT }); } catch (e) { @@ -97,7 +98,7 @@ async function sendEntity(entity, entityName, cookieJar) { uri: SYNC_SERVER + '/api/sync/' + entityName, body: payload, json: true, - timeout: 5 * 1000, + timeout: SYNC_TIMEOUT, jar: cookieJar }); } @@ -189,7 +190,7 @@ async function login() { hash: hash }, json: true, - timeout: 5 * 1000, + timeout: SYNC_TIMEOUT, jar: cookieJar }); @@ -388,8 +389,8 @@ async function updateRecentNotes(entity, sourceId) { } } -if (SYNC_SERVER) { - log.info("Setting up sync"); +if (isSyncSetup) { + log.info("Setting up sync to " + SYNC_SERVER + " with timeout " + SYNC_TIMEOUT); setInterval(sync, 60000);