I'm trying to run multiple system processes in the background.
Currently First the one process runs, and then the next. I'm trying to get them to run at the same time. When I do it manually from Terminal, I can ru multiple versions simultaneously.
This is a part of the script I'm using.
I'm looking to have the Dropbox section execute at the same time as the Google Drive section, as a separate process (running simultaneously).
sf.ui.finder.appActivate();
const rclone = '/usr/local/bin/rclone';
const rcloneDropbox = "Dropbox:Nazzy-Uploads-Dropbox";
const rcloneGoogleDrive = "Google Drive:NAZZY-Uploads-Drive";
var selectedFolder = sf.ui.finder.firstSelectedPath;
var folderName = selectedFolder.match(/([^\/]*)\/*$/)[1];
var rcloneFolderDropbox = rcloneDropbox + '/' + folderName;
var rcloneFolderGoogleDrive = rcloneGoogleDrive + '/' + folderName;
// Copy to rclone: Dropbox
sf.engine.runInBackground(() => {
sf.system.exec({
commandLine: `
"${rclone}" copy "${selectedFolder}" "${rcloneFolderDropbox}" --create-empty-src-dirs
`,
executionMode: 'Background',
});
});
// Copy to rclone: Google Drive
sf.engine.runInBackground(() => {
sf.system.exec({
commandLine: `
"${rclone}" copy "${selectedFolder}" "${rcloneFolderGoogleDrive}" --create-empty-src-dirs
`,
executionMode: 'Background',
});
});
- Christian Scheuer @chrscheuer2021-10-18 17:41:29.266Z
Hi Andrew,
Ah, I see what's going on here.
The two rclone processes you want to run here would need to each be in their own separate sub-scripts. The runInBackground and executionMode is otherwise set up correctly.
From the main script, you would then schedule the two subscripts to run by using sf.soundflow.runCommand, setting the async property to true, like this:
sf.soundflow.runCommand({ commandId: '', 'async': true, });
In commandId, you would fill in the command ID of the sub script to run. Then duplicate that for the other subscript.
Christian Scheuer @chrscheuer2021-10-18 17:43:20.868Z
Note that instead of doing all this you could also just parallellize the two calls in the bash/shell script:
Christian Scheuer @chrscheuer2021-10-18 17:44:25.952Z
Something like:
sf.system.exec({ commandLine: ` "${rclone}" copy "${selectedFolder}" "${rcloneFolderGoogleDrive}" --create-empty-src-dirs & "${rclone}" copy "${selectedFolder}" "${rcloneFolderDropbox}" --create-empty-src-dirs & wait `, });
- AAndrew Sherman @Andrew_Sherman
Thanks very much, Christian. That looks ideal. I think both approaches have their merits; I'm going to try with this one first.
- In reply toAndrew_Sherman⬆:Bill Evans @Not_Steve
Thank you - great question and thread.