How to set Procfile in Heroku in PlayFramework - heroku

Now I am trying to deploy PlayApplication, but unfortunately my deploy failed. And the error code is H10, so probably I assume the problem is setting files because my database setting must be true as I can connect database by using the created username, password and URL.
And in my understanding, Procfile just shows a command to be run toward dynos and in tutorials, in terms of Java the procfile is like this:
web: java -jar target/helloworld.jar
However, in my application, the Procfile is web: target/start -Dhttp.port=${PORT} ${JAVA_OPTS} -Dconfig.file=conf/application_prod.conf where conf/application_prod.conf is the path to the setting file. Is this Procfile right?
My play version is 2.2.1 and the official document says web: target/universal/stage/bin/retailos -Dhttp.port=${PORT} -DapplyEvolutions.default=true -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=${DATABASE_URL} is good and I can also use the option -Dconfig.file= and then you can indicate where the setting file is. This means web: target/universal/stage/bin/retailos -Dhttp.port=${PORT} -DapplyEvolutions.default=trueBut -Dconfig.file=conf/application_prod.conf. But it does not work well.
And there are many candidates about the right way being also indicted by How to create play heroku procfile?.
I am really confused. I already have written all DB settings into application_prod.conf, so I prefer to use -Dconfig.file=.
What is exactly the true one?
Thanks.

Using -Dconfig.file and similar is definitely a good idea, you do not need to set all config parameters in your Procfile.
The reason it doesn't work is probably because you're using a file path for your config file, which to my knowledge doesn't work when the application is deployed as a jar. Try this instead:
-Dconfig.resource=application_prod.conf

Related

Tell heroku which config file for Play application to load

In Play, you can use multiple config files (application.conf, prod.conf...). Usually you would have a default conf file, i.e. application.conf, and let the other files import it and overload specific values.
One case is for example when you have a production database and wand to overwrite access configuration values set by developers and use credentials only known to the production personnel.
Here is a manual on this topic that say that the wanted config is to be specified as a parameter when running the application
I am deploying my application onto Heroku, which takes care of running the application. The only peace missing here and I can't find is how to tell Heroku which config file to load?
I solved this by using a Procfile with the contents:
web: target/universal/stage/bin/my_app -Dhttp.port=$PORT -Dconfig.resource=my-special.conf
You can define environment variables for your Heroku app, e.g. using the heroku config CLI command:
heroku config:set PLAY_CONFIG_FILE=application.conf
See Heroku config vars.

gulp command in heroku procfile

I have a node.js/express app, I would like to run the command gulp build to generate my static assets when deploying with heroku, just before my node command lcm server, as I keep my public folder in my .gitignore file.
I'm having trouble finding how I can run this command during my heroku deployment.
So far my Procfile is:
web: lcm server
This doesn't seem to work -
gulp build
web: lcm server
Make a Procfile
Begin by making a blank file named Procfile and placing it within the root of your project. Procfile is short for “Process File” and used to explicitly declare what command should be executed to start your app. By default, a Procfile is not required, but it’s good form for Node-based projects to create one.
If a Procfile isn’t defined, then one will be created automatically using npm start as the web process type.
Possible solution
Try this one:
web: node node_modules/gulp/bin/gulp build
The line above lets us use the locally installed version of Gulp provided by Node’s Package Manager (NPM) instead of having to use a globally installed version.
Helpful resources
from https://www.sitepoint.com/deploying-heroku-using-gulp-node-git/

HEROKU: ps:scale web=1 no such process type web defined in Procfile

I have seen very similar posts, that however did not help me to find a solution to my problem.
I am following step by step the guide to upload a project on heroku.
However when I type the command:
ps:scale web=1
The result is:
no such process type web defined in Procfile
I have created a file "Procfile" being careful at the capitalization. but nothing.
What else can I do to solve this problem??
Thanks in advance.
Follow on this heroku procfile
:
We have to define web process type in your Procfile and make sure name Procfile exactly, and not anything else. For example, Procfile.txt is not valid.
Example:
a: Python:
web: gunicorn gettingstarted.wsgi --log-file -
b: String MVC Hibernate
web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war
This declares a single process type, web, and the command needed to run it. The name web is important here. It declares that this process type will be attached to the HTTP routing stack of Heroku, and receive web traffic when deployed.
Procfiles can contain additional process types.
worker: bundle exec rake jobs:work
Hopefully you've fixed your problem after all this time, but just in case you haven't...
I've run into this problem when my Procfile doesn't exist (a web app that I'm porting to Heroku) or doesn't match the dyno type that I'm trying to deploy (see Heroku No such process type web defined in procfile for an example of that).
You've created your Procfile, but what did you put in there? For a website Node.js app, you'll need to put in:
web: node app.js
(Obviously you'll replace app.js with index.js or wherever your app starts)
For more about Procfiles (or for other languages than Node.js), see https://devcenter.heroku.com/articles/procfile

how to create Heroku procfile for windows?

Im a newbie trying to make a django app, but unfortunately my os is windows.
Heroku docs is written for linux so I cant get sufficient information for app development on windows 7.
First how can I make procfile using window cmd?
Is there any command language translation docs?(linux->windows)
Regarding creation of text file in cmd shell:
echo web: run this thing >Procfile
this will create Procfile with web: run this thing inside (obviously).
Also You can use any text editor, notepad will fit perfectly.
And one thing, that wasn't obvious for me, therefore can also be helpfull to someone else.
Procfile should be a text file is a bit misleading, do NOT save Procfile as Procfile.txt or it will not be recognised. Just leave it plain and simple Procfile without any file format.
When you're using Windows for development, and your procfile contains for example $JAVA_OPTS (or anything else system dependent), then
besides of Procfile with Linux syntax (with for example: $JAVA_OPTS), for Heroku, you need
Procfile.windows with Windows syntax (where you can write for example" %JAVA_OPTS%), and you point to it while working with Heroku localy: heroku local web -f procfile.windows
A Procfile should be a text file, called Procfile, sitting in the root directory of your app.
It's the same for Windows or Linux or OS X.
It should specify the command Heroku should use to start your app - so it's not really about linux or windows.
So to answer your question: use a text editor. Any text editor.
Just create the file with name procfile. If your editor is intelligent enough as mine to understand the files like procfile have a Heroku icon
gunicorn doesn't work on Windows so you'll want a Procfile.windows that will locally host your app in a way that doesn't require gunicorn (such as the way you would normally do it).
web: ~what you would normally use to start your app~
web: gunicorn app_name.wsgi
write your own application name instead of app_name and file name just save without any Extention (Procfile).
A file named Procfile is required in the root of your Heroku project. The following is a basic example of the content to be created for a Django project:
web: gunicorn your_app_name.wsgi --log-file
Here the full docs from Heroku.

Installing New Relic on Heroku with Play Framework 2

I'm trying to set up new relic again (I tried some time ago with no success). I'm using heroku, and a Play 2.x application. I uploaded the newrelic agent, the yml file, everything properly configured.
Then I tried to add -javaagent:newrelic/newrelic.jar to JAVA_OPTS variable (as stated in Heroku docs), which did nothing. So I looked at the logs and found out that heroku is actually using JAVA_TOOL_OPTIONS (I think).
So I added the javaagent to that variable:
$ heroku config:set JAVA_TOOL_OPTIONS="-Djava.rmi.server.useCodebaseOnly=true -javaagent:newrelic/newrelic.jar"
After restarting the app, it looks like it actually did something because the app wouldn't start, showing this error:
"The java installation you have is not up to date requires at least version 1.6+, you have version 1.7.0_45."
I tried both with Java 6 and 7, with no success.
What am I doing wrong?
Instead of using JAVA_OPTS try to set the variable as java_opts. I know it seems strange but this should actually resolve the issue and get Heroku, Play and New Relic to be nice to one another.
You also want to modify your Procfile adding the following:
web: target/universal/stage/bin/YOUR_APP_NAME -Dhttp.port=${PORT} -J-javaagent:/app/newrelic/newrelic.jar -J-Dnewrelic.config.file=conf/newrelic.yml
Cheers
Adrienne
(TSE at New Relic. Inc)

Resources