From 76325bcc48f5f76de83b9d2755f7f56fbc02606e Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Fri, 4 Feb 2022 16:39:36 -0500 Subject: [PATCH] tweak: add hardcoded proxy as backup --- package-lock.json | 3 ++- package.json | 4 ++-- src/platforms/goodjudgment-fetch.js | 20 ++++++++++++++------ src/utils/pullSuperforecastsManually.sh | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1dc85d2..82abbf3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,8 @@ "open": "^7.3.1", "papaparse": "^5.3.0", "tabletojson": "^2.0.4", - "textversionjs": "^1.1.3" + "textversionjs": "^1.1.3", + "tunnel": "^0.0.6" } }, "node_modules/@algolia/cache-browser-local-storage": { diff --git a/package.json b/package.json index e36ab92..dcc08d0 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "test": "echo \"Error: no test specified\" && exit 1", "reload": "heroku run:detached node src/utils/doEverythingForScheduler.js", "setCookies": "./src/utils/setCookies.sh" - }, "repository": { "type": "git", @@ -37,6 +36,7 @@ "open": "^7.3.1", "papaparse": "^5.3.0", "tabletojson": "^2.0.4", - "textversionjs": "^1.1.3" + "textversionjs": "^1.1.3", + "tunnel": "^0.0.6" } } diff --git a/src/platforms/goodjudgment-fetch.js b/src/platforms/goodjudgment-fetch.js index a34244b..d42fe72 100644 --- a/src/platforms/goodjudgment-fetch.js +++ b/src/platforms/goodjudgment-fetch.js @@ -19,12 +19,20 @@ String.prototype.replaceAll = function replaceAll(search, replace) { /* Body */ export async function goodjudgment() { // Proxy fuckery - - let proxy = await axios - .get("http://pubproxy.com/api/proxy") - .then((query) => query.data); - console.log(proxy); - + let proxy; + try { + proxy = await axios + .get("http://pubproxy.com/api/proxy") + .then((query) => query.data); + console.log(proxy); + } catch (error) { + console.log("Proxy generation failed; using backup proxy instead"); + // hard-coded backup proxy + proxy = { + ip: process.env.BACKUP_PROXY_IP, + port: process.env.BACKUP_PROXY_PORT, + }; + } let agent = tunnel.httpsOverHttp({ proxy: { host: proxy.ip, diff --git a/src/utils/pullSuperforecastsManually.sh b/src/utils/pullSuperforecastsManually.sh index b1fd881..43cb5cd 100755 --- a/src/utils/pullSuperforecastsManually.sh +++ b/src/utils/pullSuperforecastsManually.sh @@ -1,4 +1,4 @@ #!/bin/bash -cd /home/loki/Documents/core/software/fresh/js/metaforecasts/metaforecasts-mongo +cd /home/loki/Documents/core/software/fresh/js/metaforecast/metaforecast-backend date > done.txt /home/loki/.nvm/versions/node/v16.8.0/bin/node ./src/utils/pullSuperforecastsManually.js >> done.txt