mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 08:32:23 +01:00
minor with taskManager
This commit is contained in:
parent
642babad94
commit
e174ca02a2
2 changed files with 7 additions and 3 deletions
|
@ -14,7 +14,7 @@ module.exports = {
|
|||
log.debug(`Remove ${places.length} unrelated places: %s`, places.map(p => p.name).join(', '))
|
||||
|
||||
const ids = places.map(p => p.id)
|
||||
await Place.destroy({
|
||||
return Place.destroy({
|
||||
where: { id: { [Sequelize.Op.in]: ids } }
|
||||
})
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ const log = require('./log')
|
|||
const placeHelpers = require('./helpers/place')
|
||||
const tagHelpers = require('./helpers/tag')
|
||||
const apHelpers = require('./helpers/ap.js')
|
||||
const { Duration } = require('luxon')
|
||||
|
||||
// const notifier = require('./notifier')
|
||||
|
||||
const loopInterval = 10 // process.env.NODE_ENV === 'production' ? 1 : 1
|
||||
|
@ -24,13 +26,15 @@ class Task {
|
|||
if (this.processInNTick > 0) {
|
||||
return
|
||||
}
|
||||
log.debug(`[TASK] Process ${this.name}`)
|
||||
this.processInNTick = this.repeatDelay
|
||||
try {
|
||||
const ret = this.method.apply(this, this.args)
|
||||
if (ret && typeof ret.then === 'function') {
|
||||
if (ret && typeof ret.catch === 'function') {
|
||||
ret.catch(e => log.error(`TASK ERROR [${this.name}]: ${e} ${e.stack}`))
|
||||
return ret
|
||||
}
|
||||
return ret
|
||||
} catch (e) {
|
||||
log.error(`TASK ERROR [${this.name}]: ${e} ${e.stack}`)
|
||||
}
|
||||
|
@ -113,7 +117,7 @@ class TaskManager {
|
|||
}
|
||||
|
||||
add (task) {
|
||||
log.info(`[TASK] Add ${task.name} (${task.repeatDelay * this.interval} seconds)`)
|
||||
log.info(`[TASK] Add ${task.name} (${Duration.fromMillis(task.repeatDelay * this.interval * 1000).rescale().toHuman({ listStyle: "long" })})`)
|
||||
this.tasks.push(task)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue