I have a Play 2.x app up and running on Heroku with a single web dyno.
On startup, an Akka actor is triggered which itself schedules future jobs (e.g. sending push n
You can also get dyno name at runtime:
String dyno = System.getenv("DYNO");
so doing a check like this may also work:
if(dyno.equals("web.1")) {
}
If you run two web dynos, your global will be executed twice. Global is global to the process. When you scale your web process, you are running two processes. You have a couple options:
GlobalSettings
implementations. When you start your process, you specify the global you want to use with -Dapplication.global=YourSecondGlobal
. In your procfile, then, you would have singleton: target/start -Dhttp.port=${PORT} ${JAVA_OPTS} -Dapplication.global=YourSecondGlobal
. Start your web processes and singleton
process and make sure singleton
is scaled to 1.