From 16c108df2eebcce676782331b6b0022bf0f53c72 Mon Sep 17 00:00:00 2001 From: RunOnFlux Date: Tue, 15 Oct 2024 09:34:33 +0000 Subject: [PATCH] Update from https://github.com/RunOnFlux/flux/commit/1285c6887b677d1cc3cd76a1508525ed9ac86757 --- services/benchmarkService.js | 3 +- services/syncthingService.js | 98 ++++++++++++++++++---------------- services/systemService.js | 6 +-- services/utils/daemonConfig.js | 8 +-- 4 files changed, 59 insertions(+), 56 deletions(-) diff --git a/services/benchmarkService.js b/services/benchmarkService.js index b7f75a28..fdec68cb 100644 --- a/services/benchmarkService.js +++ b/services/benchmarkService.js @@ -17,7 +17,8 @@ let response = messageHelper.createErrorMessage(); let benchdClient = null; async function buildBenchdClient() { - const fluxbenchdPath = '/dat/usr/lib/fluxbenchd'; + const homeDirPath = path.join(__dirname, '../../../../'); + const fluxbenchdPath = path.join(homeDirPath, '.fluxbenchmark'); const exists = await fs.stat(fluxbenchdPath).catch(() => false); diff --git a/services/syncthingService.js b/services/syncthingService.js index 77277e92..3150d601 100644 --- a/services/syncthingService.js +++ b/services/syncthingService.js @@ -51,39 +51,38 @@ const stc = new FluxController(); * @returns {Promise<(string | null)>} config gile (XML). */ async function getConfigFile() { - // const homedir = os.homedir(); - // const configDir = path.join(homedir, '.config'); - // const syncthingDir = path.join(configDir, 'syncthing'); - // const configFile = path.join(syncthingDir, 'config.xml'); - const configFile = '/dat/usr/lib/syncthing/config.xml'; + const homedir = os.homedir(); + const configDir = path.join(homedir, '.config'); + const syncthingDir = path.join(configDir, 'syncthing'); + const configFile = path.join(syncthingDir, 'config.xml'); - // const user = os.userInfo().username; - // const owner = `${user}:${user}`; + const user = os.userInfo().username; + const owner = `${user}:${user}`; // As syncthing is running as root, we need to change owenership to running user - // const { error: chownConfigDirError } = await serviceHelper.runCommand('chown', { - // runAsRoot: true, - // logError: false, - // params: [owner, configDir], - // }); + const { error: chownConfigDirError } = await serviceHelper.runCommand('chown', { + runAsRoot: true, + logError: false, + params: [owner, configDir], + }); - // if (chownConfigDirError) return null; + if (chownConfigDirError) return null; - // const { error: chownSyncthingError } = await serviceHelper.runCommand('chown', { - // runAsRoot: true, - // logError: false, - // params: [owner, syncthingDir], - // }); + const { error: chownSyncthingError } = await serviceHelper.runCommand('chown', { + runAsRoot: true, + logError: false, + params: [owner, syncthingDir], + }); - // if (chownSyncthingError) return null; + if (chownSyncthingError) return null; - // const { error: chmodError } = await serviceHelper.runCommand('chmod', { - // runAsRoot: true, - // logError: false, - // params: ['644', configFile], - // }); + const { error: chmodError } = await serviceHelper.runCommand('chmod', { + runAsRoot: true, + logError: false, + params: ['644', configFile], + }); - // if (chmodError) return null; + if (chmodError) return null; let result = null; // this should never reject as chown would error first but just in case @@ -2495,11 +2494,10 @@ async function runSyncthingSentinel() { log.error('Unable to get syncthing deviceId. Reconfiguring syncthing.'); await stopSyncthing(); await installSyncthingIdempotently(); - // await configureDirectories(); + await configureDirectories(); - // const homedir = os.homedir(); - // const syncthingHome = path.join(homedir, '.config/syncthing'); - const syncthingHome = '/dat/usr/lib/syncthing'; + const homedir = os.homedir(); + const syncthingHome = path.join(homedir, '.config/syncthing'); const logFile = path.join(syncthingHome, 'syncthing.log'); if (stc.aborted) return 0; @@ -2517,26 +2515,32 @@ async function runSyncthingSentinel() { // adding old spawn with shell in the interim. childProcess.spawn( - 'nohup', - [ - 'syncthing', - '--logfile', - logFile, - '--logflags=3', - '--log-max-old-files=2', - '--log-max-size=26214400', - '--allow-newer-config', - '--no-browser', - '--home', - syncthingHome, - ], - { - detached: true, - stdio: 'ignore', - env: { HOME: syncthingHome }, - }, + `sudo nohup syncthing --logfile ${logFile} --logflags=3 --log-max-old-files=2 --log-max-size=26214400 --allow-newer-config --no-browser --home ${syncthingHome} >/dev/null 2>&1