Compare commits
No commits in common. "41d06f7e9d2f076757ec8ae8bb1aca51deba3acc" and "99cfd3dc3fdf51de1ef0ba8f0cc51807de44a000" have entirely different histories.
41d06f7e9d
...
99cfd3dc3f
|
@ -1,17 +1,9 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
database: {
|
database: {
|
||||||
owner: {
|
host: '127.0.0.1',
|
||||||
host: '127.0.0.1',
|
user: 'user',
|
||||||
user: 'user',
|
password: 'password',
|
||||||
password: 'password',
|
database: 'traxxx',
|
||||||
database: 'traxxx',
|
|
||||||
},
|
|
||||||
query: {
|
|
||||||
host: '127.0.0.1',
|
|
||||||
user: 'user',
|
|
||||||
password: 'password',
|
|
||||||
database: 'traxxx',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
web: {
|
web: {
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
const config = require('config');
|
const config = require('config');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: config.database.owner,
|
connection: config.database,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.184.2",
|
"version": "1.184.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "1.184.2",
|
"version": "1.184.1",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@graphile-contrib/pg-order-by-related": "^1.0.0-beta.6",
|
"@graphile-contrib/pg-order-by-related": "^1.0.0-beta.6",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "traxxx",
|
"name": "traxxx",
|
||||||
"version": "1.184.2",
|
"version": "1.184.1",
|
||||||
"description": "All the latest porn releases in one place",
|
"description": "All the latest porn releases in one place",
|
||||||
"main": "src/app.js",
|
"main": "src/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -5,7 +5,7 @@ const knex = require('knex');
|
||||||
|
|
||||||
module.exports = knex({
|
module.exports = knex({
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: config.database.owner,
|
connection: config.database,
|
||||||
// performance overhead, don't use asyncStackTraces in production
|
// performance overhead, don't use asyncStackTraces in production
|
||||||
asyncStackTraces: process.env.NODE_ENV === 'development',
|
asyncStackTraces: process.env.NODE_ENV === 'development',
|
||||||
// debug: process.env.NODE_ENV === 'development',
|
// debug: process.env.NODE_ENV === 'development',
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const config = require('config');
|
const config = require('config');
|
||||||
const Promise = require('bluebird');
|
|
||||||
const bhttp = require('bhttp');
|
const bhttp = require('bhttp');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
|
@ -16,12 +15,7 @@ const argv = require('../argv');
|
||||||
const pipeline = util.promisify(stream.pipeline);
|
const pipeline = util.promisify(stream.pipeline);
|
||||||
const limiters = {};
|
const limiters = {};
|
||||||
|
|
||||||
Promise.config({
|
|
||||||
cancellation: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
timeout: 60000,
|
|
||||||
encodeJSON: true,
|
encodeJSON: true,
|
||||||
headers: {
|
headers: {
|
||||||
'user-agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1',
|
'user-agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1',
|
||||||
|
@ -73,7 +67,6 @@ function getLimiter(options = {}, url) {
|
||||||
limiters[interval][concurrency] = new Bottleneck({
|
limiters[interval][concurrency] = new Bottleneck({
|
||||||
minTime: interval,
|
minTime: interval,
|
||||||
maxConcurrent: concurrency,
|
maxConcurrent: concurrency,
|
||||||
timeout: (options.timeout || defaultOptions.timeout) + 10000, // timeout 10 seconds after bhttp should
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +83,7 @@ async function request(method = 'get', url, body, requestOptions = {}, limiter)
|
||||||
...defaultOptions.headers,
|
...defaultOptions.headers,
|
||||||
...requestOptions.headers,
|
...requestOptions.headers,
|
||||||
},
|
},
|
||||||
responseTimeout: requestOptions.responseTimeout || requestOptions.timeout || defaultOptions.timeout,
|
responseTimeout: requestOptions.responseTimeout || requestOptions.timeout || 60000,
|
||||||
stream: !!requestOptions.destination,
|
stream: !!requestOptions.destination,
|
||||||
session: null,
|
session: null,
|
||||||
};
|
};
|
||||||
|
@ -138,25 +131,10 @@ async function request(method = 'get', url, body, requestOptions = {}, limiter)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimeout(options, url) {
|
|
||||||
return new Promise((resolve, reject, onCancel) => {
|
|
||||||
const timeoutId = setTimeout(() => {
|
|
||||||
reject(new Error(`URL ${url} timed out`));
|
|
||||||
}, (options.timeout || defaultOptions.timeout) + 10000);
|
|
||||||
|
|
||||||
onCancel(() => clearTimeout(timeoutId));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function scheduleRequest(method = 'get', url, body, options) {
|
async function scheduleRequest(method = 'get', url, body, options) {
|
||||||
const limiter = getLimiter(options, url);
|
const limiter = getLimiter(options, url);
|
||||||
const timeout = getTimeout(options, url);
|
|
||||||
|
|
||||||
const result = await limiter.schedule(() => Promise.race([request(method, url, body, options, limiter), timeout]));
|
return limiter.schedule(() => request(method, url, body, options, limiter));
|
||||||
|
|
||||||
timeout.cancel();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function get(url, options) {
|
async function get(url, options) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ const PgOrderByRelatedPlugin = require('@graphile-contrib/pg-order-by-related');
|
||||||
|
|
||||||
const { ActorPlugins, SitePlugins, ReleasePlugins } = require('./plugins/plugins');
|
const { ActorPlugins, SitePlugins, ReleasePlugins } = require('./plugins/plugins');
|
||||||
|
|
||||||
const connectionString = `postgres://${config.database.query.user}:${config.database.query.password}@${config.database.query.host}:5432/${config.database.query.database}`;
|
const connectionString = `postgres://${config.database.user}:${config.database.password}@${config.database.host}:5432/${config.database.database}`;
|
||||||
|
|
||||||
module.exports = postgraphile(
|
module.exports = postgraphile(
|
||||||
connectionString,
|
connectionString,
|
||||||
|
|
Loading…
Reference in New Issue