How to see PM2 restart history (node-pm2) - pm2

Is it possible to see the restart log/history with PM2 app?
I saw my nodeJS app restarted a few times but no clue when.
I've checked pm2 documentation but no luck.

PM2 logs are streamed into the file ˜/.pm2/pm2.log

You can run the command: pm2 logs for an output of all logs, relating to running apps and their error logs.
The first log file in the window will be the default PM2 ones, for this kind of information.

Related

pod not found error, while using the rsync cmd to copy the results from ocp pod to jenkins workspace

I am running some automated tests using RBF, but sometimes when the test runner is complete and am trying to copy the test result from OCP to local using Rsync (using Jenkins job), it shows that the pod is not found, but test cases were run on the same pod, after restarting the pod this error is resolved, but after some time again this error comes. Can anyone tell me what is the root cause of this error and the solution for this?
tried to start rollout the pod, but this does not fix the problem permantely, after some run the error comes again

`pm2 web` command not found. How to start pm2 web server?

I'm using pm2 version 4.4.0 and trying to start the pm2 web server.
Is 'pm2 web' deprecated? If yes, how do I get the CPU and memory metrics using pm2 API?
I am trying to create a Grafana dashboard for pm2 following this article:
https://medium.com/#nikunjd.np/pm2-microservices-monitoring-with-grafana-influxdb-54fb6f8b5d2d

PM2 keeps getting killed every 90 seconds on centos 8

I just installed CentOS 8 and added nodejs (tried v12 & v14) And then I installed pm2 using npm install pm2#latest (so at the time of posting it uses v4.4.0). I did try an older version (v3.5.0), but it does the exact same thing.
and after pm2 got installed, i ran the command "pm2 startup"
after a restart, pm2 does start, but gets killed after 90 seconds and then restarts giving this message
"pm2 has been killed by signal, dumping process list before exit..."
First, I thought it was because of my app (the one that pm2 is supposed to manage), but i removed it from pm2, so it's practically empty, but it does the same thing
Running the following command as root worked for me:
pm2 update
I had the same issue and I tried several solutions online but none worked for me.
However, I completely removed pm2, restarted the server, and reinstalled pm2 and that does it for me.
1- Stop and remove pm2
pm2 kill
sudo npm remove pm2 -g
2- Restart the server
sudo reboot
3- Log in again, then reinstall pm2
sudo npm install -g pm2
I did not disable SE Linux (I think it's not safe to disable it), but the following method helped me:
Edit file: /etc/systemd/system/pm2-root.service
Add new line: Environment=PM2_PID_FILE_PATH=/run/pm2.pid
And replace: PIDFile=/root/.pm2/pm2.pid to: PIDFile=/run/pm2.pid
Versions:
CentOS 8.3.2011
Node.js 14.16.0
NPM 7.7.5
PM2 4.5.5
Original answer. Thanks Alec!
Later update. For those who are facing the same issues. It's an issue related to SE Linux. Known workarounds (the ones I discovered).
Disabling SE Linux (obviously, not recommended)
go to /etc/systemd/system/pm2-root.service - comment PIDFile=... (add a # in front of that line)
Audit and trace - use following commands:
# dnf install policycoreutils-python-utils setroubleshoot-server -y
# journalctl -f
At ths point, you should see the solution in the output (the log)
it should be something like:
# ausearch -c 'systemd' --raw | audit2allow -M my-systemd
# semodule -i my-systemd.pp
You need to do the last step (ausearch... and semodule...) twice - I did it once, restarted the machine and noticed the same issue after 90 seconds. But if you read the log carefully, you will notice that the issue seems to be outputed twice. (looks the same). Probably two things are trying to write to that file (pm2-root.service).
Still waiting for the perfect solution (done by the person that really knows how to fix this in a proper manner), but for those that have this issue, any of these options seem to work just fine.
I've had this problem (on Debian), when for some reason two "PM2 God Daemon" processes (not threads) were launched, so they conflicting with each other.
Killing one of them solved the issue.

How do I force PM2 to use the latest version of my app?

I first invoked PM2 with pm2 start index.js --watch --ignore-watch "node_modules". However, despite telling it to watch my files for changes and then reload, it is not using the latest version of my app when I pull from git.
To test this:
$ git show
new version commit message
$ pm2 describe index | grep comment
old version commit message
So PM2 is using a cached version.
I tried to reload the app manually, using pm2 reload index:
$ pm2 reload index
[PM2] Applying action reloadProcessId on app [index](ids: 0)
[PM2] [index](0) ✓
However, it's still not using the latest version of my app. pm2 describe index | grep comment shows exactly the same old version commit message.
The only way I am able to get it to work is running pm2 kill and then pm2 resurrect, but that's not a satisfactory solution. It's too slow!
Is PM2 doing some caching? I've read through all of their docs and done an extensive search but can't figure this out.
After further testing this appears to be a bug in PM2's reporting of the git commit. The version being served is actually the latest version, but PM2 is reporting the out-of-date one. Bug report published.

Sphinx Not Running as Windows Service

For the longest time, I have been able to run Sphinx as a Windows Service by running the following commands:
indexer.exe --all --config ../sphinx.conf
c:\Sphinx\bin\searchd.exe --install --config c:\Sphinx\sphinx.conf --servicename Sphinx
For whatever, this stopped working today. Now, I am receiving the dreaded 1067 error. A look at the even logs provides no real information.
The only way to run this application is from the console:
>searchd.exe -c ../sphinx.conf
Can anyone provide any insight?