I have a node app used only in a scheduler. But heroku keeps trying to call npm start on in.
State changed from starting to crashed
Process exited with status 1
State changed from crashed to starting
Starting process with command `npm start`
Even with a dummy worker in Procfile:
worker: echo 1
There's always a web process added at deploy:
Default types for Node.js -> web
Any ideas on how I could get rid of heroku continuously trying to npm start?
Not really a direct solution, but you could easily scale down your web processes to 0.
heroku ps:scale web=0
Related
CI/CD services will often use SUCCEDED or FAILED to display if a deployment succeded and if an error occurred. However, with PM2 this is not so easy.
If you do:
pm2 start ecosystem.config.js in one of your deployment steps, PM2 will start the process but won't report an error if one of the processes fails. To check it, you would need to execute pm2 status, and then judging by the number of restarts and by executing pm2 logs --err you would be able to see what happens. I would like PM2 to return a non-zero code or be verbose about a process failing on first launch, rather than what it does now (failing silently).
Is there a native PM2 command that makes it integrate with CI/CD release status reporting easily?
What I want to achieve:
pm2 start ecosystem.config.js
# one of the processes in ecosystem.config.js fails, because eg. the database engine is not running and the driver can't connect to the db
# pm2 prints to stderr and a failure shows up on my CI/CD service. pm2 closes and returns non-zero if it failed to launch one of the processes
What's happening currently:
pm2 start ecosystem.config.js
# one of the processes fails
# no error is printed, everything is ok according to pm2. pm2 keeps running and the problematic process fails silently
I'm trying to deploy me node application which is running sucessfully running on localhost. For this, I have installed heroku cli on my machine, and I'm opening GIT cli to do the following:
Heroku Login -- successful
git push heroku master -- trying to push to an existing heroku app.
I've already deleted the heroku app it is refering to. Still it is pointing to the same app.
Even after reopening the git cli, it is pointing me to that and push is failing (git push heroku master)
Here the question is,
How to point my git to a newly created heroku app (everytime I'm creating a new app not knowing the command to point to the existing app)
Thanks in advance.
The easier way to add your heroku app remote reference is running the command below from your git folder:
heroku git:remote -a name-of-your-heroku-app
to verify if the remote heroku ref was correctly added you can run:
git remote -v
When running the application using the heroku open command, facing the following issue. Any clue where i went wrong..?
2018-11-12T18:59:19.888307+00:00 app[api]: Scaled to web#1:Free by user *********#email.com
2018-11-12T18:59:19.867050+00:00 app[api]: Deploy 77ec2d50 by user *************#email.com
2018-11-12T18:59:25.456322+00:00 heroku[web.1]: Starting process with command node mp3.js
2018-11-12T18:59:29.846039+00:00 heroku[web.1]: State changed from starting to crashed
2018-11-12T18:59:29.848349+00:00 heroku[web.1]: State changed from crashed to starting
2018-11-12T18:59:29.804086+00:00 heroku[web.1]: Process exited with status 127
2018-11-12T18:59:29.620089+00:00 app[web.1]: bash: node: command not found
I accidentally added npm start in the heroku post build process so now the build progress is stuck.
I did git push heroku master the build started normal and my server started as it should when running npm start, but because the npm start was in the post build it never finished. Because I'm on free account I only have one concurrent build process and because of the one stuck I can't build new version.
I already tried heroku ps -a APP_NAME and then heroku ps:kill web.1 for the single process that was running, but it didn't help.
ty
Heroku has a CLI Plugin with which you can manage your builds.
heroku builds -a example-app # take note of the build ID you'd want to display
heroku builds:cancel <id> -a example-app
In case anybody reading this might still need it!
I am running my node application on AWS EC2 server.
For continuous integration I installed Jenkins, on EC2, jenkins polls a code commit continuously and when a commit occurs executes some commands written in a script.
The last command is
pm2 start server.js
Everything works fine and the build is shown successful but later when I access the URL the site doesn't show.
I have a nginx server in front of node server, it gives
502 Bad Gateway
On checking I realised the node application is not running, so I cehcked pm2 logs and found this happening -
2016-08-12 07:53:28: [[[[ PM2/God daemon launched ]]]]
2016-08-12 07:53:28: BUS system [READY] on port /var/lib/jenkins/.pm2/pub.sock
2016-08-12 07:53:28: RPC interface [READY] on port /var/lib/jenkins/.pm2/rpc.sock
2016-08-12 07:53:28: Starting execution sequence in -fork mode- for app name:server id:0
2016-08-12 07:53:28: App name:server id:0 online
2016-08-12 07:53:28: pm2 has been killed by signal, dumping process list before exit...
2016-08-12 07:53:28: Deleting process 0
2016-08-12 07:53:28: Stopping app:server id:0
2016-08-12 07:53:28: App [server] with id [0] and pid [25822], exited with code [0] via signal [SIGTERM]
2016-08-12 07:53:28: Proc is not defined anymore or is being killed
2016-08-12 07:53:28: [PM2] Exited peacefully
pm2 is getting killed as soon as starting, don't know why, tried reinstalling pm2 from npm didn't work.
Ubuntu 14.04 LTS
Node v4.4.7 LTS
npm v2.15.8
pm2 v1.1.3
Work is halted, need help immediately, please.
The answer is in the comments given by Dusan Bajic, if anyone is doing continous integration with jenkins on EC2 using a node application and similar thing happens with pm2 just add this line in script before starting pm2.
export BUILD_ID=dontKillMePlease
and instead of
pm2 start server.js
use
pm2 restart server.js
server.js being your application or else build will fail if in jenkins if you commit and it runs script again cause pm2 is already running server.js and won't stop.
From ProcessTreeKiller
To reliably kill processes spawned by a job during a build, Jenkins
contains a bit of native code to list up such processes and kill them
...
How it works
The ProcessTreeKiller takes advantage of the fact that by
default a new process gets a copy of the environment variables of its
spawning/creating process.
It sets a specific environment variable in the process executing the
build job. Later, when the user requests to stop the build job's
process it gets a list of all processes running on the computer and
their environment variables, and looks for the environment variable
that it initially set for the build job's process.
Every job with that environment variable in its environment is then
terminated.
If your build wants to leave a daemon running behind...
A convenient way to achieve that is to change the environment variable
BUILD_ID which Jenkins's ProcessTreeKiller is looking for. This will
cause Jenkins to assume that your daemon is not spawned by the Jenkins
build. For example:
BUILD_ID=dontKillMe /usr/apache/bin/httpd
Is it necessary to give 'worker' information in Procfile? If yes then what it is actually? I have already added web: node server/server.js detail in the Procfile.
Procfile is a mechanism for declaring what commands are run by your application’s dynos on the Heroku platform.
From Process Types and the Procfile, which is a good introduction, but basically you use the Procfile to tell Heroku how to run various pieces of your app. The part to the left of the colon on each line is the process type; the part on the right is the command to run to start that process.
Process types can be anything, although web is special, as Heroku will route HTTP requests to processes started with the web name. Other processes, such as background workers, can be named anything, and you can use the Heroku toolbelt to start or stop those processes by referring to its name.
So, in short, worker is not necessary, unless you want to run some other process in the background by controlling process with the heroku ps command.
You would only need a 'worker' entry in your Procfile if you plan on using some sort of background job system (i.e. queuing long running tasks for later). Heroku has more information here:
https://devcenter.heroku.com/articles/procfile
I was following Udemy course regarding nestjs and aws Elastic Beanstalk to deploy however it keeps failing to deploy until I created Procfile with following:
web: npm install && npm run-script build && npm run-script start:prod