Skip to content

Commit

Permalink
Simple proxy support (not tested)
Browse files Browse the repository at this point in the history
Tries to read 'proxySettings' string from config.json. If it was
provided, sets it to --all-proxy parameter when running aria2c
and https_proxy environment variable when running satellite (node)
Refere to these links:
nodejs/node#8381
https://github.com/request/request#controlling-proxy-behaviour-using-environment-variables
  • Loading branch information
heylel-b-sh committed Nov 6, 2020
1 parent e4deed6 commit b570db2
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions electron/SatelliteApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class SatelliteApp {

airflowSettings;
satelliteSettings;
proxySettings;
token;
initComplete;

Expand Down Expand Up @@ -72,6 +73,7 @@ export class SatelliteApp {

this.airflowSettings = this.store.get('airflowSettings', null);
this.satelliteSettings = this.store.get('satelliteSettings', null);
this.proxySettings = this.store.get('proxySettings', null);

this.pm2_home = path.join(app.getPath('home'), '/.pm2');

Expand Down Expand Up @@ -316,11 +318,15 @@ export class SatelliteApp {
*
*/
startPM2Aria2c() {
let cmd_args = ['--enable-rpc', '--rpc-listen-all=false', `--rpc-listen-port=${this.satelliteSettings.aria2cPort}`,
'--console-log-level=debug', '--auto-file-renaming=false']
if (this.proxySettings) {
cmd_args.push(`--all-proxy=${this.proxySettings}`)
}
const options = {
name: 'aria2c',
script: `${this.services_base_path}/aria2c`,
args: ['--enable-rpc', '--rpc-listen-all=false', `--rpc-listen-port=${this.satelliteSettings.aria2cPort}`,
'--console-log-level=debug', '--auto-file-renaming=false'],
args: cmd_args,
watch: false,
exec_mode: 'fork_mode',
cwd: `${this.satelliteSettings.scidapRoot}/files`
Expand Down Expand Up @@ -436,22 +442,26 @@ export class SatelliteApp {
*
*/
startSatellite() {
let env_var = {
MONGO_URL: `mongodb://localhost:${this.satelliteSettings.mongoPort}/scidap-satellite`,
ROOT_URL: `${this.satelliteSettings.baseUrl}`,
PORT: `${this.satelliteSettings.port}`,
METEOR_SETTINGS: this.getSatelliteConf(),
NODE_OPTIONS: '--trace-warnings --pending-deprecation',
PATH: `${this.services_base_path}:${this.airflow_base_path}/Resources/app/bin:` +
`${this.airflow_base_path}/Resources/app_packages/bin:/usr/bin:/bin:/usr/local/bin`,
}
if (this.proxySettings) {
env_var["https_proxy"] = `${this.proxySettings}`
}
const options = {
name: 'satellite',
script: `${this.services_base_path}/../main.js`,
interpreter: 'node',
watch: false,
exec_mode: 'fork_mode',
cwd: `${this.satelliteSettings.scidapRoot}`,
env: {
MONGO_URL: `mongodb://localhost:${this.satelliteSettings.mongoPort}/scidap-satellite`,
ROOT_URL: `${this.satelliteSettings.baseUrl}`,
PORT: `${this.satelliteSettings.port}`,
METEOR_SETTINGS: this.getSatelliteConf(),
NODE_OPTIONS: '--trace-warnings --pending-deprecation',
PATH: `${this.services_base_path}:${this.airflow_base_path}/Resources/app/bin:` +
`${this.airflow_base_path}/Resources/app_packages/bin:/usr/bin:/bin:/usr/local/bin`,
}
env: env_var
};
return this.startPM2(options);
}
Expand Down

0 comments on commit b570db2

Please sign in to comment.