From b570db22320875edcf1faefca39a982b1943227e Mon Sep 17 00:00:00 2001 From: heylel-b-sh Date: Fri, 6 Nov 2020 16:45:26 -0500 Subject: [PATCH] Simple proxy support (not tested) 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: https://github.com/nodejs/node/issues/8381 https://github.com/request/request#controlling-proxy-behaviour-using-environment-variables --- electron/SatelliteApp.ts | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/electron/SatelliteApp.ts b/electron/SatelliteApp.ts index 63e9583..c896a4d 100644 --- a/electron/SatelliteApp.ts +++ b/electron/SatelliteApp.ts @@ -31,6 +31,7 @@ export class SatelliteApp { airflowSettings; satelliteSettings; + proxySettings; token; initComplete; @@ -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'); @@ -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` @@ -436,6 +442,18 @@ 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`, @@ -443,15 +461,7 @@ export class SatelliteApp { 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); }