From f86fb0d0a200e09c3100269258c02dffe4c8e1ad Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 6 Jan 2023 15:14:04 +0100 Subject: [PATCH] added TRILIUM_SYNC_SERVER_HOST env. variable to prevent prod sync issues --- package.json | 8 ++++---- src/services/sync_options.js | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index efa080246..0bf95ccc2 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,10 @@ "url": "https://github.com/zadam/trilium.git" }, "scripts": { - "start-server": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev node ./src/www", - "start-server-no-dir": "cross-env TRILIUM_ENV=dev node ./src/www", - "start-electron": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev electron --inspect=5858 .", - "start-electron-no-dir": "cross-env TRILIUM_ENV=dev electron --inspect=5858 .", + "start-server": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 node ./src/www", + "start-server-no-dir": "cross-env TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 node ./src/www", + "start-electron": "cross-env TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron --inspect=5858 .", + "start-electron-no-dir": "cross-env TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 electron --inspect=5858 .", "switch-server": "rm -rf ./node_modules/better-sqlite3 && npm install", "switch-electron": "rm -rf ./node_modules/better-sqlite3 && npm install && ./node_modules/.bin/electron-rebuild", "build-backend-docs": "rm -rf ./docs/backend_api && ./node_modules/.bin/jsdoc -c jsdoc-conf.json -d ./docs/backend_api src/becca/entities/*.js src/services/backend_script_api.js src/services/sql.js", diff --git a/src/services/sync_options.js b/src/services/sync_options.js index a63b89514..28ec9cca3 100644 --- a/src/services/sync_options.js +++ b/src/services/sync_options.js @@ -15,7 +15,9 @@ function get(name) { } module.exports = { - getSyncServerHost: () => get('syncServerHost'), + // env variable is the easiest way to guarantee we won't overwrite prod data during development + // after copying prod document/data directory + getSyncServerHost: () => process.env.TRILIUM_SYNC_SERVER_HOST || get('syncServerHost'), isSyncSetup: () => { const syncServerHost = get('syncServerHost');