Question

I have a heavy process which downloads data off APIs which I want to schedule with 'Heroku Scheduler'. (https://addons.heroku.com/scheduler)

I want a dedicated worker process for the job. How should I define my Procfile?

How should I define the worker task in scheduler plugin settings page?

enter image description here

Was it helpful?

Solution

I'm assuming that you're using rails. If you're not, then you'll have to change the instructions slightly, but the general instructions work.

You'll need a command to run your data downloader. In Rails, the best way to do this would be to create a rake command in /lib/tasks/scheduler.rake called api_data_downloader for example.

If you're not using rails then create a script (You can place it in bin).

Then to add the job, go to your app on the Heroku dashboard. Click on 'general info', then on the scheduler add-on. Click 'add a job' and select a frequency and time. For the job, input the command that would run your script. For Rails, you would run 'rake api_data_downloader'. Otherwise you may need to do something such as 'ruby api_data_downloader.rb' or 'php api_data_downloader' depending on your needs'.

You can read the blog post on the scheduler app or read the documentation on it.

The scheduler app is a one-off dyno not a worker dyno. The scheduler add-on is meant for short tasks and worker dynos for processes that take longer than a couple minutes. If you need a worker dyno, then in your procfile you need to specify

worker: rake api_data_downloader

and scale it up with

heroku ps:scale worker=1

The scheduler add-on and a worker dyno are different from each other.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top