Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RunOnFluxBot committed Dec 10, 2024
1 parent dbd784e commit a898ea8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 52 deletions.
4 changes: 4 additions & 0 deletions services/fluxshareService.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,10 @@ async function fluxShareFileExists(req, res) {
let { file } = req.params;
file = file || req.query.file;

if (!file) {
throw new Error('No File specified');
}

const filepath = path.join(appsFolder, 'ZelShare', file);
let fileExists = true;
try {
Expand Down
104 changes: 52 additions & 52 deletions services/syncthingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2501,58 +2501,58 @@ async function stopSyncthingSentinel() {
* @returns {Promise<void>}
*/
async function ensureSyncthingRunning(installed) {
if (!installed || !await getDeviceId()) {
log.error('Unable to get syncthing deviceId. Reconfiguring syncthing.');
await stopSyncthing();
await installSyncthingIdempotently();
await configureDirectories();
if (installed && await getDeviceId()) return;

const homedir = os.homedir();
const syncthingHome = path.join(homedir, '.config/syncthing');
const logFile = path.join(syncthingHome, 'syncthing.log');

log.info('Spawning Syncthing instance...');

// if nodeJS binary has the CAP_SETUID capability, can then set the uid to 0,
// without having to call sudo. IMO, Flux should be run as it's own user, not just
// whatever the operator installed as.
// this can throw

// having issues with nodemon and pm2. Using pm2 --no-treekill stops syncthing getting
// killed, but then get issues with nodemon not dying.

// adding old spawn with shell in the interim.

childProcess.spawn(
`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 </dev/null &`,
{ shell: true },
).unref();

// childProcess.spawn(
// 'sudo',
// [
// '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',
// // uid: 0,
// },
// ).unref();

// let syncthing set itself up
await stc.sleep(5 * 1000);
}
log.error('Unable to get syncthing deviceId. Reconfiguring syncthing.');
await stopSyncthing();
await installSyncthingIdempotently();
await configureDirectories();

const homedir = os.homedir();
const syncthingHome = path.join(homedir, '.config/syncthing');
const logFile = path.join(syncthingHome, 'syncthing.log');

log.info('Spawning Syncthing instance...');

// if nodeJS binary has the CAP_SETUID capability, can then set the uid to 0,
// without having to call sudo. IMO, Flux should be run as it's own user, not just
// whatever the operator installed as.
// this can throw

// having issues with nodemon and pm2. Using pm2 --no-treekill stops syncthing getting
// killed, but then get issues with nodemon not dying.

// adding old spawn with shell in the interim.

childProcess.spawn(
`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 </dev/null &`,
{ shell: true },
).unref();

// childProcess.spawn(
// 'sudo',
// [
// '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',
// // uid: 0,
// },
// ).unref();

// let syncthing set itself up
await stc.sleep(5 * 1000);
}

/**
Expand All @@ -2569,7 +2569,7 @@ async function runSyncthingSentinel() {

try {
if (!process.env.SYNCTHING_PATH) {
await ensureSyncthingRunning();
await ensureSyncthingRunning(installed);
}

if (stc.aborted) return 0;
Expand Down

0 comments on commit a898ea8

Please sign in to comment.