esbenp/pdf-bot

Run faster than once per minute?

jeremyhaile opened this issue · 1 comments

Since cron runs at most once per minute, a PDF job sent to pdf-bot may take one minute to process even if pdf-bot is not busy at the time.

Is there a way to have a shift:all run automatically when an API push is triggered? Or is there a trick to getting pdf-bot to process more quickly?

Its not super elegant but I have added 2 things in 48fe04d

  • At the end of shift:all it will run again until there are no more unfinished jobs in the queue
  • Added postPushCommand to API configuration. You can use it like this:
api: {
    // The port your express.js instance listens to requests from. (default: 3000)
    port: 3000,
    // Spawn command when a job has been pushed to the API
    postPushCommand: ['/home/user/.npm-global/bin/pdf-bot', ['-c', './pdf-bot.config.js', 'shift:all']],
    // The token used to validate requests to your API. Not required, but 100% recommended.
    token: 'api-token'
},

it will spawn a process using postPushCommand as arguments after a job has been pushed to the queue