How does Heroku knows which file use to deploy? - heroku

I always create a file called server.js as entry point of my Node.js app and I always deploy to Heroku with that file but... How does Heroku know that server.js the file that it should to execute?
What if my server file is called anotherName.js? How can I tell to Heroku to deploy anotherName.js?

If you have a Procfile, Heroku will look there first.
If no Procfile exists, Heroku will try to run the start sript defined in your package.json.
What if my server file is called anotherName.js? How can I tell to Heroku to deploy anotherName.js?
Either by modifying (or creating) your Procfile or by changing the start script in your package.json.

Related

Heroku run Jar file once deployed?

I have deployed my jar file to heroku using:
heroku deploy:jar <filename>.jar --app <appname>
Once deployed, how do I run the jar file with specific params, i.e. locally i would execute:
java -jar <filename>.jar <param1> <param2>
Am i using the Heroku service correctly? In essence I just need to run the Main command within the jar file and get the logs when completed.
Any help would be much appreciated.
heroku deploy:jar <filename>.jar --app <appname>
With this you essentially hardcorded:
jar <filename>.jar
Here is an example where you can configure parameters for your command
https://github.com/NNTin/shell-kun/tree/6b35e4b731bcf500366f60bbceafe076bf969fe1
Note: We are looking here at older software because HEAD no longer has it.
You need Procfile. app.json and the Heroku Deploy (see link in README.md) button are optional. They make deploying easier since you don't have to touch terminal/CLI.
Essentially you extend your Procfile to:
web: jar <filename>.jar $ARGS_AND_FLAGS
worker: jar <filename>.jar $ARGS_AND_FLAGS
web when you are utilizing a $PORT, worker when not.
Now you can modify your command by editing the environment variable ARGS_AND_FLAGS.
In this case the web process is activated and the worker process is deactivated.
After you changed your environment variable you can deactivate and then activate your process.
Create a Procfile in the same directory where you run heroku deploy:jar with the content:
web: java -jar <filename>.jar <param1> <param2>
and redeploy the app.

AngularJS - Deploy on Heroku

I created a app for Angular manually, his structure and all stuff.
To run it locally I'm using http-server.
How can I deploy it to Heroku in order to inform what server to run (probably in Procfile)?
Create a Procfile just called Procfile (no extension) in the root of your app. Within that file use web: to tell heroku what to run. For example:
web: coffee server.coffee

Procfile in Heroku

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.

Setting up an existing Heroku application on a new machine

I've an existing project that works fine on another machine, but I've just upgraded and from within the project development directory, everytime I run a heroku command I have to post-fix it with --app
I feel like I've missed an application setup stage, but I can't figure out what, as everytime it states:
Run this command from an app folder or specify which app to use with --app APP.
Help appreciated.
You can solve this by adding the Heroku app to your .git/config folder.
If you are in the root of your project, run the following command:
git remote add heroku git#heroku.com:appname.git
This will set a line in your .git/config file which the heroku command line tool uses to figure out what app you're using :)
In other words, your local repo doesn't have Heroku app URL configured against an app name
Similarly what we do with git remote add ( we pass git URL as a destination for push/pulling of code )
that how our git know which repo/URL to hit (push/pull from )
Heroku also follows the same method/process.
All you have to do is add Heroku app URL (so that ur Heroku command have a reference for app URL )
it will know against which URL you are running your command against
To confirm if remote named Heroku has been set for your app:
git remote -v
if not configured or if you want it for an existing app
heroku git:remote -a app_name
it's a way to link your folder to the Heroku app
The Heroku recommended way:
heroku git:remote -a my-heroku-app-id -r what-i-want-to-call-it
Source: https://devcenter.heroku.com/articles/git
Run this command from an app folder or specify which app to use with --app APP
The other answers address the first part of that statement, it is perfectly acceptable to run heroku commands in any directory. For example I have a customer facing front end project /front-end and a rails based /back-end project. I often work in the /front-end directory and if I have to connect to the production database I'll run heroku run rails c -a back-end. After I exit irb then I'm back in my desired directory.

Heroku procfile "No such process type web defined in Procfile" error

This is the first time I've used Heroku, and the fact that I can't find anyone in Google with a similar error to this means I'm likely doing something way wrong:
I'm following the basic Heroku setup guide here to get my NodeJS application deployed to the web. I'm deployed and trying to check my dynos with:
heroku ps:scale web=1
However, when I do this I get the error:
Scaling web dynos... failed
! No such process type web defined in Procfile.
When I run heroku ps I get nothing returned.
In my app's root directory, I have a file named Procfile (with no extension) which contains:
web: node app.js
The app runs locally without any issues (using foreman start).
Question is why is this occurring, how do I remedy it, should I even care?
Processes to be run on Heroku are defined in a simple text file called: Procfile
The Profile contains a line that defines how each of the processes in your application will run. This will be language specific and examples can be seen on the Heroku Devcenter Procfile article
Please note that the Procfile must be spelt exactly, with the first letter capitalized an all others lower case. There is no file extension for the Procfile. This Procfile should be placed in the root of your project and committed to your local git repository before doing a git push heroku master.
Should you mis-type the filename after it has been added to git, you can rename it using git with the command
git mv ProcFile Procfile
The renamed file will be staged so you can commit the changed file with the command
git commit -m "corrected name of Procfile"
I found the solution myself, from here: https://stackoverflow.com/a/7641259/556006
I had the same problem and I just now I found what was wrong. I first
accidently called the file ProcFile instead of Procfile. Simply
renaming that file did not get picked up by git. I had to do a git rm
ProcFile -f first and then add a new (correctly named) Procfile. After
that, it got pushed correctly by git and got picked up correctly by
Heroku.
I just had this issue myself, but in my case, I was missing a space between web: and the starting command in the Procfile.
For example, I had it wrong this way:
web:gunicorn run:app
Fixed it by adding a space after the colon:
web: gunicorn run:app
I am guessing you've never done git push heroku master -- that is, Heroku has never seen your code.

Resources