Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended way to run single server scheduled play! jobs on heroku?

Is there a way to get a scheduled job to run on a single server? We have an email sending job that I don't want running twice simultaneously. Is this what heroku workers are for? I am currently under the impression that play! jobs actually run on web workers. Thanks!

like image 452
Matt Hall Avatar asked Feb 23 '23 03:02

Matt Hall


2 Answers

We've been using Play! (not on Heroku) and found the easiest way was to define a framework id for the servers you want to run the jobs, and a framework id for the servers that won't run the jobs.

In our case, "prodapp" are the Production Application servers that don't run jobs, and "prodadmin" is the Production Admin/Job server (only one).

We've included the following in our application.conf to disable the jobs plugin on the prodapp servers:

%prodapp.plugins.disable=play.jobs.JobsPlugin

I'm not sure it's the best solution, but after investigating some other options, we determined it to be the quickest to implement without forking the Play! source code.

like image 98
Jordan Satok Avatar answered Mar 05 '23 17:03

Jordan Satok


I sent a support ticket to Heroku for the same query. They advised not to use Play scheduled jobs, but to instead use the Scheduler add-on instead.

I don't think you can specify a server id within Heroku, so you cannot distinguish one web server from another, and therefore cannot only use one instance for jobs like you could if you had control over the number of servers you were spinning up.

like image 37
Codemwnci Avatar answered Mar 05 '23 17:03

Codemwnci