tweak: add hardcoded proxy as backup

This commit is contained in:
NunoSempere 2022-02-04 16:39:36 -05:00
parent 9bda1c2558
commit 76325bcc48
4 changed files with 19 additions and 10 deletions

3
package-lock.json generated
View File

@ -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": {

View File

@ -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"
}
}

View File

@ -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,

View File

@ -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