scheduler.js 690 B

12345678910111213141516171819202122232425262728
  1. const PgBoss = require('pg-boss')
  2. /* global WIKI */
  3. module.exports = {
  4. scheduler: null,
  5. jobs: [],
  6. init () {
  7. WIKI.logger.info('Initializing Scheduler...')
  8. this.scheduler = new PgBoss({
  9. ...WIKI.models.knex.client.connectionSettings,
  10. application_name: 'Wiki.js Scheduler',
  11. schema: WIKI.config.db.schemas.scheduler,
  12. uuid: 'v4'
  13. })
  14. return this
  15. },
  16. async start () {
  17. WIKI.logger.info('Starting Scheduler...')
  18. await this.scheduler.start()
  19. WIKI.logger.info('Scheduler: [ STARTED ]')
  20. },
  21. async stop () {
  22. WIKI.logger.info('Stopping Scheduler...')
  23. await this.scheduler.stop()
  24. WIKI.logger.info('Scheduler: [ STOPPED ]')
  25. }
  26. }