sdfsdf
This commit is contained in:
@@ -14,7 +14,7 @@ class SeleniumBrowser {
|
|||||||
let uri = params.uri
|
let uri = params.uri
|
||||||
logger.info('URL %s', uri)
|
logger.info('URL %s', uri)
|
||||||
if (uri.indexOf('://') > 3) {
|
if (uri.indexOf('://') > 3) {
|
||||||
return this.pool.acquire()
|
return poolingService.acquire()
|
||||||
.then(async driver => {
|
.then(async driver => {
|
||||||
let html = await driver.get(uri)
|
let html = await driver.get(uri)
|
||||||
.then(() => driver.findElement(By.css('body')))
|
.then(() => driver.findElement(By.css('body')))
|
||||||
|
|||||||
@@ -12,22 +12,26 @@ class PoolingService {
|
|||||||
browserArgs: ['--no-sandbox', '--headless', '--disable-dev-shm-usage', '--proxy-server=spiduler-tor:8118']
|
browserArgs: ['--no-sandbox', '--headless', '--disable-dev-shm-usage', '--proxy-server=spiduler-tor:8118']
|
||||||
}
|
}
|
||||||
this.pool = this.createPool()
|
this.pool = this.createPool()
|
||||||
this.pool.on("factoryCreateError", function (err) {
|
}
|
||||||
console.log('factoryCreateError', err);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.pool.on("factoryDestroyError", function (err) {
|
acquire() {
|
||||||
console.log('factoryDestroyError', err);
|
return this.pool.acquire().catch(err => this.pool.acquire())
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createPool() {
|
createPool() {
|
||||||
setInterval(() => this.debugPoolStatus(), 1000 * 60 * 5)
|
setInterval(() => this.debugPoolStatus(), 1000 * 60 * 5)
|
||||||
return pool.createPool({
|
let pool = pool.createPool({
|
||||||
create: () => this.create(),
|
create: () => this.create(),
|
||||||
destroy: (driver) => this.destroy(driver),
|
destroy: (driver) => this.destroy(driver),
|
||||||
validate: (driver) => this.validate(driver)
|
validate: (driver) => this.validate(driver)
|
||||||
}, this.config.pool);
|
}, this.config.pool);
|
||||||
|
this.pool.on("factoryCreateError", function (err) {
|
||||||
|
logger.debug({reason: err.message}, 'factoryCreateError');
|
||||||
|
});
|
||||||
|
this.pool.on("factoryDestroyError", function (err) {
|
||||||
|
logger.debug({reason: err.message}, 'factoryDestroyError');
|
||||||
|
});
|
||||||
|
return pool
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
|
|||||||
Reference in New Issue
Block a user