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

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.

Related

Installing Mysql innodb cluster v8 with ansible

I want to install mysql v8 with ansible by downloading repo ( mysql-apt-config_0.8.15-1_all.deb )
and install it with dpkg,when i want to manually without ansible install, it prompts a window to choose version and some configs and then i should click ok for adding the repo and updating the apt repo and so on
The problem comes in when i want to install repo and mysql package with ansible
Now how can i do this and solve my problem with prompt window in ansible?
Thanks for your answer.

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 to see PM2 restart history (node-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.

TortoiseHg 3.6.3 broke mercurial keyring?

I upgraded to Tortoise 3.6.3 yesterday and now I am prompted every time I pull or push a repo. The keyring is set properly, and my user name is in the url.
Any ideas on what may be wrong? Did 3.6.3 break keyring?
Issue 4401 "mercurial_keyring always asks for user/password" from time of 3.6.2 closed as pure extension-specific and contains solution: don't use username in URL anymore
Here is what to put into .hg/hgrc:
[auth]
default.username=myname
default.prefix=http://myrepo
A good way to debug issues like this is to run merciural from the command line with the debug flag, as in:
hg pull --debug
This will clearly indicate if there are problems getting the repo, user name, and password.
UPDATE: A new version of TortoiseHG has been released (3.8.3 at the time of writing) and fixes this issue: upgrading to latest version should be enough.
I had this exact same problem and found the following investigation article to be quite helpful to better understand what't going on (I'm not the author, BTW).
To cut it short, it seems a bug of the mercurial_keyring extension v1.0.1, introduced in TortoiseHG 3.6.2, which also appears to be fixed in v1.1.1.
If you're into Python compiling, it should be possible to upgrade it manually into TortoiseHG by getting it from its official bitbucket repo, compile it and manually place it into TortoiseHG's /lib/library.zip file (backup it beforehand might be wise): if you're not, you have 2 options:
1) clone the bitbucket repo to your HDD and then configure your Mercurial installation to use the new version of that extension module by writing the following in your C:\Users\USERNAME\mercurial.ini file (which was what I did):
[extensions]
mercurial_keyring = /path/to/mercurial_keyring/mercurial_keyring.py
(Notice: you might also have to put the path in your PATH or PYTHONPATH env variable, depending if you already have Python and/or Mercurial installed on your machine).
2) wait for the next TortoiseHG release that will contain the updated version.

Mercurial on Jenkins, installing and configuring

I have a Mercurial repository (on Bitbucket) with some code (Java) and I want to do CI builds on a cloud-based Jenkins server (at Jelastic, running on CentOS). My problem is that I haven't been able to do a proper installation of Mercurial on the Jenkins server.
The Jenkins build fails with the following message:
ERROR: Failed to clone https://bitbucket_jenkins_user:some_password#bitbucket.org/repo_owner/my_repository because hg could not be found; check that you've properly configured your Mercurial installation
Setup information
It's a private Mercurial repository, hosted at Bitbucket
In Bitbucket I have set up a Service to trigger the Jenkins build, after a Push has happened
I have defined a specific bitbucket jenkins user in my Mercurial repository, it has only read rights and it logs in using simple https authentication
Jenkins runs on a Tomcat 7, hosted in a Jelastic cloud environment, on CentOS 6
The Mercurial plugin was installed through the Jenkins interface, by Manage plugins
The build is configured as being triggered remotely (by the service defined in Bitbucket)
Build results are the same when started manually and when triggered from a push to the repository
When I first did this I was under the impression that installing the Mercurial plugin in Jenkins would be enough, that it would also install the needed Mercurial binaries to be able to connect to the repository and get the code. I have realized that I was wrong and that on the Manage Jenkins / Configure System page I need to specify my Mercurial installation.
Questions
Is it possible to create a Mercurial installation without ssh access and doing a "yum install mercurial"?
In the Jenkins interface, what can I specify when choosing the "Install Automatically" option?
When defining an installer, I have experimented with the "Extract zip/tar.gz" option, but what can I write as the "Download URL for binary archive"?
Jenkins also offers an installer option of "Run command". What kind of commands could that be, maybe a "yum install ..." or "rpm ..."?
Since my server is cloud based, getting ssh access is a paid add-on which I would prefer to avoid. But if that is my only option I will of course do it, thereby getting access to running commands on the server. However, running "yum install mercurial" on Centos seems to only give the 1.4 version of Mercurial. Current version when I write this is 2.6.3, would I need to download the sources and compile it myself or is it possible to get that as a binary for Centos somewhere?
The Mercurial Plugin page has a section on how to use the Auto Installation options to install Mercurial using ArchLinux packages.
"The plugin supports generic tool auto-installation methods for your Mercurial installation, though it does not publish a catalog of Mercurial versions. For users of Linux machines (with Python preinstalled), you can use ArchLinux packages. For example, in /configure under Mercurial installations, add a Mercurial installation with whatever Name you like, Executable = INSTALLATION/bin/hg, Install automatically, Run Command, Label = linux (if desired to limit this to slaves configured with the same label), Command = [ -d usr ] || wget -q -O - http://www.archlinux.org/packages/extra/i686/mercurial/download/ | xzcat | tar xvf - (or …/x86_64/… for 64-bit slaves), Tool Home = usr, and configure a job with this installation tied to a Linux slave."
see https://wiki.jenkins-ci.org/display/JENKINS/Mercurial+Plugin