I'm trying to install New Relic, but it says I'll need to make changes to Procfile. I can't seem to find it at the root of the local copy of my app though. I'm using Django.
Thanks
This page on Heroku gives a lot more information on what the procfile is:
https://devcenter.heroku.com/articles/procfile
You don't have to have one to deploy to Heroku, but you can manually create one to take more control over how Heroku runs your apps. As per this excerpt from the link above:
A Procfile is not necessary to deploy apps written in most languages supported by Heroku. The platform automatically detects the language, and creates a default web process type to boot the application server.
Creating an explicit Procfile is recommended for greater control and flexibility over your app.
For Heroku to use your Procfile, add the Procfile to the root of your application push to Heroku:
$ git add .
$ git commit -m "Procfile"
$ git push heroku
...
-----> Procfile declares process types: web, worker
Compiled slug size is 10.4MB
-----> Launching... done
http://strong-stone-297.herokuapp.com deployed to Heroku
To git#heroku.com:strong-stone-297.git
* [new branch] master -> master
For New Relic support, you have to explicitly tell Heroku to run a gunicorn instance within New Relic. So your Procfile would look something like this:
newrelic-admin run-program gunicorn --workers 4 --worker-class gevent --timeout 60 mysite.wsgi
You can turn this on or off without changing your Procfile by conditionally looking for your New Relic licence in the Heroku environment variables:
Procfile:
web: bash scripts/heroku_run
scripts/heroku_run:
#!/bin/bash
run_command="gunicorn --workers 4 --worker-class gevent --timeout 60 mysite.wsgi"
# Run through New Relic monitoring if add-on installed
if [[ $NEW_RELIC_LICENSE_KEY != '' ]]; then
newrelic-admin run-program $run_command
else
$run_command
fi
Related
Im trying to host my object detection api on heroku but i can't due to it not recognizing my
Procfile, which is a file and not a text file. the way its spelled is Procfile, its contents are
web:gunicorn app:app
the way i know that its the Procfile thats the problem is because when i run bash and look at the root directory of the heroku git i see Procfile but when i look at the logs i see that no web process is running and on the dashboard the dynos is completely empty.
i've tried doing
web: gunicorn app: app instead of web:gunicorn app:app
to no avail, i've made sure that gunicorn is in the requirements.txt and know that its pip installing the requirements.txt as the cmd tells me that it is when i do git push heroku master. i've tried doing echo>Procfile and then modifying the contents of the file. i've tried both echo "web:gunicorn app:app"> Procfile and echo web:gunicorn app:app>Procfile i tried doing heroku ps:scale web=1 and get Scaling web dynos... failed ! No such process type web defined in Procfile. and when i do heroku ps i get nothing
I am trying to host a discord bot on Heroku (Discord JDA, Maven). I do this by connecting to Github and then deploying. The bot 'deploys' (view attachment) but doesn't actually work (view attachment).
What could I be doing wrong, or has anyone else come across a similar issue?
Quick and dirty way to deploy it:
You'll need to setup a Procfile, extensive info on that right here: https://devcenter.heroku.com/articles/procfile
The procfile is basically a file with no extension that tells the dyno how to execute your program.
A simple
worker: java $JAVA_OPTS -jar <PATH_TO_JAR>
will work fine if you don't need more config, refer to that link for more.
You can then deploy it like this (Good to have procfile and jar on the same directory):
$ heroku deploy:jar -a <YOUR_HEROKU_APP_NAME> --jdk <JDK_VERSION> --jar <PATH_TO_JAR> -i Procfile
Then to start it just do (Assuming you want a worker dyno, which is what discord should need)
$ heroku ps:scale -a <YOUR_HEROKU_APP_NAME> worker=1
Then stop it with:
$ heroku ps:scale -a <YOUR_HEROKU_APP_NAME> worker=0
I've found this is much simpler than using git, especially if you're doing tests or simple/quick stuff.
Possible solutions:
Set up a Procfile. A Procfile basically tells Heroku what command to run when your app is deployed. Inside the Procfile, write worker: node index.js. Also, make sure Procfile has a capital "P".
Set up package.json.
npm init
Then just skip through the set up and your file should be automatically created. IMPORTANT. In your package.json file, add your node and npm versions.
node -v
npm -v
Then go an type this in your package.json.
"engines": {
node: "your-version-here"
npm: "your-version-here"
}
Then try deploying your app to Heroku again. Also, make sure you have the "nodejs" buildpack set up for your app. Run it and test the discord bot.
I am following the tutorial here
but I got the error
Scaling dynos... !
▸ Couldn't find that process type (web).
when doing
heroku ps:scale web=1
I followed the solution here
by delete the buildpack and use heroku buildpacks:set heroku/python
But the error still happend
and for buildpacks:
heroku buildpacks
=== teaching-system Buildpack URL
heroku/python
it seem to be correct
What is wrong with it?
This is what I did to past this error in Django. It's on Windows10
Add Procfile -in the same folder where you have git, manage.py
Procfile
-------------------------------
web: gunicorn <django-root-name(containing wsgi)>.wsgi --log-file -
Installing gunicorn(for later use)
>python -m pip install gunicorn
Clearing BuildPacks & fixing them
>heroku buildpacks:clear
>heroku buildpacks:add heroku/python
commit(empty-commit) & push
>git commit --allow-empty -m "Adjust push heroku master"
git push heroku master
That's what made me pass this scaling dyno.. blah blah
Update:
For local development, add following file
Procfile.windows
------------------------------------------
web: python manage.py runserver 0.0.0.0:5000
Make sure that you have a Procfile that is in the same directory as your Pipfile and Pipfile.lock files.
I'm using django and in Procfile I had:
#Procfile
web: gunicorn <my_project_name>.wsgi --log-file -
Install gunicorn if you haven't already. I had the same error and spent a long time trying to resolve it so I hope this helps. The syntax will change depending on what framework and language you're using, but the idea should be similar.
in Django,i solved creating the next files:
--------------------------------------------
**Procfile.windows** :
web: python manage.py runserver 0.0.0.0:5000
-------------------------------------------
**requirements.txt** :
django
gunicorn
django-heroku
------------------------------------------
**runtime.txt** :
python-3.7.7
-------------------------------------------------------
**Procfile** :
web: gunicorn <name of my main folder app>.wsgi --log-file -
----------------------
**.env** :
TIMES=2
----------------------
and after just do a commit to local repository,so the steps will be:
*
heroku login
heroku create
git commit -m "gogogo heroku"
git push heroku master
heroku ps:scale web=1
heroku open
*
I solved this problem a few week later in another Flask project
It was caused by loosing library: gunicorn in current virtual environment
It may have happened if you have modified your Procfile or renamed it after pushing to Heroku master. If so, you can try to make it work by rebuilding the index.
In my case this worked:
remove cached files (only the paths are removed from the index, not the real files!!!)
git rm -r --cached .
add all files to the index
git add .
commit
git commit -m "hopefully fixed error"
run rest of the heroku commands again
worked for me! hope it does for you.
I'm trying to set up Phoenix 1.2 so that I have two Heroku environments: one for dev/testing (which will keep the this-app-12345.herokuapp.com url), and a standard production environment.
Currently, I set up my app the usual way:
mix phoenix.new my_app
cd my_app
mix ecto.create
mix ecto.migrate
git init && git add . && git commit -m "Initial commit"
heroku create
This gives me a Heroku instance:
Creating app... done, ⬢ first-instance-12345
https://first-instance-12345.herokuapp.com/ | https://git.heroku.com/first-instance-12345.git
I then add the buildpacks, change the config/ files and run git push heroku master and everything works.
Now I'd like to create another Heroku instance, to which I can also deploy. If I run heroku create again, I get:
Creating app... done, ⬢ second-instance-23456
https://second-instance-23456.herokuapp.com/ | https://git.heroku.com/second-instance-23456.git
If I replace the url in prod.exs with the new instance...
config :my_app, MyApp.Endpoint,
http: [port: {:system, "PORT"}],
url: [scheme: "https", host: "second-instance-23456.herokuapp.com", port: 443], force_ssl: [rewrite_on: [:x_forwarded_proto]],
...and then commit and run git push heroku master, it will still deploy to first-instance-12345.herokuapp.com, which isn't what I want.
Re-running buildpacks doesn't help either.
$ heroku buildpacks:add https://github.com/HashNuke/heroku-buildpack-elixir
▸ The buildpack https://github.com/HashNuke/heroku-buildpack-elixir is already set on your app.
$ heroku buildpacks:add https://github.com/gjaldon/phoenix-static-buildpack
▸ The buildpack https://github.com/gjaldon/phoenix-static-buildpack is already set on your app.
Is there a standard method (or any method) to get Phoenix to deploy to multiple heroku environments? (And hopefully specify which one/s on deploy)
The standard way to deploy an app to multiple Heroku apps is to add multiple remotes to the repo and push to the one you want to deploy to. Making that change to config/prod.exs will have no effect on where the app is deployed.
Here's how to add the two remotes:
$ git remote add first https://git.heroku.com/first-instance-12345.git
$ git remote add second https://git.heroku.com/second-instance-23456.git
Now you can deploy to the first one using:
$ git push first master
and to the second using:
$ git push second master
Certainly the best way to do so is to have two different instances as #dogbert wrote.
Also remember about changing Procfile for heroku, because you want to run app using different environments eg.
# Procfile for prod
web: MIX_ENV=prod mix phoenix.server
# Procfile for dev
web: MIX_ENV=dev mix phoenix.server
For both environments you would need to apply migrations:
heroku run MIX_ENV=<env> ecto.migrate
Can somebody help me regarding on how can i solve my problem on Heroku. Im new to Heroku.
This warning always appear. WARNING:No Procfile detected, using the default web server (webrick). Im using Rails 4. Thank in advance
The error itself is pretty self-explanatory. No Procfile is detected, so in your root directory create a file called Procfile.
As you stated in your comment you are using the Unicorn server so inside the Procfile put this code.
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
I am assuming you created a unicorn.rb file
push to github, push to heroku and see if that works.
The Procfile holds the command for starting the server, and any options you need to pass to that. Your app was crashing because the command to start the server was not there at all.