質問

I have a play 1.2.5 app running on heroku and I want to swap out all jobs into a worker dyno, so they don't scale with the web dynos.

To do that, I need to differentiate, if the application is running on a web or a worker dyno.

Is there any way to accomplish that by passing a command line argument using the procfile?

Currently I see, that by passing custom CLI arguments the JVM fails to be created...

Thanks you in advance!

役に立ちましたか?

解決 2

Okay, I found it myself:

By adding a -D parameter to the procfile, I can determine the environment play is running in.

So my procfile's going to look like:

web: play run --http.port=$PORT $PLAY_OPTS
worker: play run --http.port=$PORT $PLAY_OPTS -Dprocesstype=worker

By using

System.getProperty("processtype");

I can ensure, that i am on a worker dyno and process my jobs only then.

他のヒント

Heroku uses web as the process type for web dynos.

You need to declare your dynos in your Procfile where you can specify their process types.

You can use any identifier you like, but worker is suggested and seems like a good convention to use.

You can then scale your individual dynos types using:

heroku ps:scale web=1

or

heroku ps:scale worker=1

Also, this post has a good answer that might help you.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top