This commit is contained in:
spiduler
2020-10-23 16:01:00 +09:00
parent 495e4bf0c4
commit 3bca3c0ea2

View File

@@ -25,6 +25,13 @@ class SeleniumBrowser {
return driver.quit() return driver.quit()
}, },
validate: (driver) => { validate: (driver) => {
logger.debug({
spare: this.pool.spareResourceCapacity,
size: this.pool.size,
available: this.pool.available,
borrowed: this.pool.borrowed,
pending: this.pool.pending
}, 'Pool info')
return driver.getSession().then(s => { return driver.getSession().then(s => {
logger.info('Driver session validation checked (id: %s)', s.getId()) logger.info('Driver session validation checked (id: %s)', s.getId())
return true return true
@@ -46,25 +53,18 @@ class SeleniumBrowser {
logger.error({ message: err.message }, 'pool error') logger.error({ message: err.message }, 'pool error')
}) })
this.pool.use(driver => { // this.pool.use(driver => {
logger.debug({ // return new Promise((resolve, reject) => {
spare: this.pool.spareResourceCapacity, // if (this.pool.available == 0) this.config.browserFullCount++
size: this.pool.size, // if (this.config.browserFullCount > 100) {
available: this.pool.available, // this.pool.clear()
borrowed: this.pool.borrowed, // this.config.browserFullCount = 0
pending: this.pool.pending // reject(new Error('browser full count more than 100 times'))
}, 'Pool info') // } else {
return new Promise((resolve, reject) => { // resolve(driver)
if (this.pool.available == 0) this.config.browserFullCount++ // }
if (this.config.browserFullCount > 100) { // })
this.pool.clear() // })
this.config.browserFullCount = 0
reject(new Error('browser full count more than 100 times'))
} else {
resolve(driver)
}
})
})
} }
getDriver() { getDriver() {