This commit is contained in:
spiduler
2020-10-24 23:53:44 +09:00
parent 15a81262f0
commit afa299dae3

View File

@@ -15,6 +15,18 @@ class SeleniumBrowser {
} }
this.capabilities = Capabilities.chrome() this.capabilities = Capabilities.chrome()
this.sleep = m => new Promise(r => setTimeout(r, m)) this.sleep = m => new Promise(r => setTimeout(r, m))
setInterval(this.createPool, 1000 * 60)
}
reCreatePool() {
this.pool.drain().then(() => {
return this.pool.clear()
}).then(() => {
this.createPool()
})
}
createPool() {
this.pool = pool.createPool({ this.pool = pool.createPool({
create: () => { create: () => {
logger.info('Create new driver instance') logger.info('Create new driver instance')
@@ -31,7 +43,7 @@ class SeleniumBrowser {
pending: this.pool.pending pending: this.pool.pending
}, 'Pool info') }, 'Pool info')
}).catch(err => { }).catch(err => {
logger.debug({message: err.message}, 'Quitting error') logger.debug({ message: err.message }, 'Quitting error')
this.pool.release(driver) this.pool.release(driver)
}) })
}, },