notbrain
notbrain

Reputation: 3396

How to create play heroku procfile?

I am following the directions here

http://blog.heroku.com/archives/2011/8/29/play/

but I do play run and then git push heroku master but a procfile is not found.

-----> No Procfile found. Will use process: 
       play run --http.port=$PORT $PLAY_OPTS
  1. How do I explicitly create a procfile?
  2. The instructions seem to indicate that I should push to heroku master while the app is running. Am I reading that wrong?
  3. Where can I specify $PORT and $PLAY_OPTS for mydomain.herokuapp.com?
  4. Is it better to just modify the values for %prod in application.conf?

Upvotes: 12

Views: 24753

Answers (3)

Mosty Mostacho
Mosty Mostacho

Reputation: 43464

It will considerably depend on the play version you're using. I checked the docs and found the following Procfiles for each of the given versions:

  • 1.x

    web: play run --http.port=$PORT $PLAY_OPTS
    
  • 2.0

    web: target/start -Dhttp.port=${PORT} ${JAVA_OPTS}
    
  • 2.2.0

    web: bin/<your-appname> -Dhttp.port=${PORT} ${JAVA_OPTS} -DapplyEvolutions.default=true
    
  • 2.2.1

    web: target/universal/stage/bin/<your-appname> -Dhttp.port=${PORT} -DapplyEvolutions.default=true
    

For more information for the specific version check this URL:

http://www.playframework.com/documentation/2.2.1/ProductionHeroku

Make sure you replace 2.2.1 with whatever version you're using.

Upvotes: 8

timkral
timkral

Reputation: 211

  1. Creating a Procfile is as simple as it sounds. Just create a file called Procfile and declare your process types and commands. More information is here: http://devcenter.heroku.com/articles/procfile In this case, you didn't provide a Procfile so Heroku just used the standard Play process. It's best practice to explitly provide a Procfile in case this default changes in the future.

  2. No, you are not reading that wrong. To upload a new version of your app you perform a git push to heroku.

  3. The $PORT variable is set internally by Heroku. No need to set it. The $PLAY_OPTS variable is set in your app space when you first push your Play app to Heroku. You can see it using the heroku command line. More information on that command line is here: http://devcenter.heroku.com/articles/heroku-command

To view your app configuration:

$ heroku config

To change $PLAY_OPTS:

$ heroku config:remove PLAY_OPTS
$ heroku config:add PLAY_OPTS=...

By default, heroku will run Play apps under the prod framework id. You can change this in your Procfile or in the $PLAY_OPTS variable. The only important thing here is that your app run in PROD mode on heroku (note that mode is different from framework id). Heroku cannot run Play apps in DEV mode.

Upvotes: 10

John Beynon
John Beynon

Reputation: 37507

You need to create a file named Procfile in the root of your project and for Play it should contain

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

When you then deploy your application the $PORT and $PLAY_OPTS will be set by heroku when the application is started.

Upvotes: 18

Related Questions