PM2 keeps getting killed every 90 seconds on centos 8 - pm2

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.

Related

I am trying to install MySql on Debian 10 and keep getting an error. What am I doing wrong?

I keep trying to install either MySql or MariaDb on a fresh installation of Debian 10. Should be a simple process,(sudo apt-get install mariadb-server mariadb-client)
but I keep getting this error:
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mariadb-client : Depends: mariadb-client-10.4 (>=
1:10.4.7+maria~buster) but it is not going to be installed
mariadb-server : Depends: mariadb-server-10.4 (>=
1:10.4.7+maria~buster) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
This is a fresh install. PHP and Apache2 are installed. I have tried several times using first MySql and then when that didn't work, I tried using MariaDb, but still get the same error. Not sure what else to do. I tried googling and the only thing close suggested ensuring that it wasn't installed and even purging any previous installations. I tried that but still doesn't work.
After working with this about 4 hours, I finally figured it out. When installing Debian, I was presented with some options regarding software to install. One of those options was to install Web server software. So, I chose to do so. That was a mistake. First, you don't get all of the needed php modules by selected that option. Secondly, that selection does install some of what is needed for MySql, but not enough to actually work.
So, in the end, for anyone else who has this issue, this is how I fixed it.
First, run the commands:
sudo service mysql stop
sudo apt-get --purge remove "mysql*"
sudo rm -rf /etc/mysql/
Then, make sure everything is gone by running
sudo updatedb
locate mysql
You will still see a few things, but make sure that you don't see a my.cnf file. That was the culprit in my case. If you do see it, delete it as well.
Now reinstall MySql and you shouldn't have any issues. If you are also installing phpMyAdmin, you will still need to run one more command to get the needed extensions.
sudo apt install php-imagick php-phpseclib php-php-gettext php7.3-common
php7.3-gd php7.3-imap php7.3-json php7.3-curl php7.3-zip php7.3-xml
php7.3-mbstring php7.3-bz2 php7.3-intl php7.3-gmp

When I type "libvirtd --listen" in linux shell, there is error "GNUTLS support not available in this build"

I was doing some experiment on live migration using virsh. When I input anything related to tls, such as "# virsh -c qemu+tls://source/system",or "libvirtd --listen", there would be errors like "GNUTLS support not available in this build". So, here is what I tried to fix it:
Reinstall libvirt with --with-gnutls
#yum install gnutls-devel
#sh ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib64 --with-gnutls
After it successfully installed, reload it
# systemctl daemon-reload
# systemctl restart libvirtd
then I tried again my experiment, still there are errors "GNUTLS support not available in this build".
Any hints helpful will be appreciated sincerely.
Create TLS certificate first, follow the instruction on libvirt official website. Then reinstall libvirt again, everything goes right.

how to save iptables changes in fedora 22

After every restart the changes I make to iptables are lost. I know now that I have to save the changes after making them, but every way of saving I tried so far doesn't work.
I tried the following :
/etc/init.d/iptables save (command not found)
/usr/libexec/iptables.init save (command not found)
/sbin/service iptables save (the service supports only basic lsb actions)
I'm just a basic *nix user, so most of my knowledge is based on uncle Google and I cannot find more solutions at the moment. Any help would be appreciated.
I'm on Fedora 22 64-bit.
As Fedora uses firewalld in recent versions, you need to do it with firewalld commands. Take a look here
If you insist to use iptables, you need to install iptables in order to use iptables-save and iptables-restore commands using dnf install iptables .

Error using YUM and DNF in Fedora 21

I read this article in fedoramagzine.org and followed the process. Since then I am unable to perform updates, installation etc from both yum and dnf.
This is the error I get from DNF
Abhinav#localhost ~$ sudo dnf update
[sudo] password for Abhinav:
Error: Failed to synchronize cache for repo 'fedora' from
'https://mirrors.fedoraproject.org/metalink?repo=fedora-21&arch=x86_64':
Cannot prepare internal mirrorlist: Curl error: Timeout was reached
for
https://mirrors.fedoraproject.org/metalink?repo=fedora-21&arch=x86_64
[Connection timed out after 120002 milliseconds]
and this is the error I get when using YUM
Abhinav#localhost ~$ sudo yum update Loaded plugins: langpacks
One of the configured repositories failed (Fedora 21 - x86_64), and
yum doesn't have enough cached data to continue. At this point the
only safe thing yum can do is fail. There are a few ways to work
"fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Disable the repository, so yum won't use it by default. Yum will then
just ignore the repository until you permanently enable it again or use
--enablerepo for temporary usage:
yum-config-manager --disable fedora
4. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=fedora.skip_if_unavailable=true
Cannot retrieve metalink for repository: fedora/21/x86_64. Please
verify its path and try again
I even emptied all the repos in /etc/yum.repos.d except for the original 3 repos you get when you install distro.
UPDATE ::
#Etan Reisner Here is the output of rpm -qa nss\*
Abhinav#localhost ~$ rpm -qa nss\*
nss-softokn-freebl-3.17.3-1.fc21.x86_64
nss-util-devel-3.17.3-1.fc21.x86_64 nss-sysinit-3.17.3-2.fc21.x86_64
nss-util-3.17.3-1.fc21.x86_64 nss-tools-3.17.3-2.fc21.x86_64
nss-softokn-freebl-3.17.3-1.fc21.i686 nss-3.17.3-2.fc21.x86_64
nss-softokn-freebl-devel-3.17.3-1.fc21.x86_64
nss-mdns-0.10-15.fc21.x86_64 nss-mdns-0.10-15.fc21.i686
nss-util-3.17.3-1.fc21.i686 nss-softokn-3.17.3-1.fc21.i686
nss-devel-3.17.3-2.fc21.x86_64 nss-softokn-devel-3.17.3-1.fc21.x86_64
nss-3.17.3-2.fc21.i686 nss-softokn-3.17.3-1.fc21.x86_64
UPDATE 2
Formatted my laptop and re-installed Fedora 21. After 3 sudo dnf updates. I am stuck with this problem again. This time i didn't follow the steps on the previous article.
On further google search I found https://fedorahosted.org/fedora-infrastructure/ticket/4517 which talks about same error. It is closed but I can't find a proper solution again.
If you sit behind a proxy, you have to configure dnf accordingly. (Even if the user's proxy settings are fine, you have to set them for dnf anyway.) The dnf settings are stored in /etc/dnf/dnf.conf. The syntax is:
proxy=<protocol>://<ip or name>:<port>
If this is not your problem, try to download the metadata with the browser to ensure, that your network connection to the url is working.
The file to receive should be an xml file. If you cannot download the metadata via the browser, chances are, that either port 443 (for https) is blocked or there is something wrong with your internet connection.
Issue
Had similar errors with kubernete (k83) while starting Fedora 23 VM master with vagrant
Error: Failed to synchronize cache for repo 'updates' from
System Spec
OS
Darwin Kernel Version 15.6.0: Wed Nov 2 20:30:56 PDT 2016; root:xnu-3248.60.11.1.2~2/RELEASE_X86_64 x86_64
Vagrant
Installed Version: 1.9.2 Latest Version: 1.9.2
Fedora
Fedora23 x86_64
RCA
While logged into fedora23VM , running yum update in verbose mode
sudo yum --verbose update a curl timeout on downloading from each of the repository presented in the metalink.
e.g
error: Curl error (56): Failure when receiving data from the peer for http://ftp.polytechnic.edu.na/pub/fedora/linux/updates/23/x86_64/repodata/af3c46471b1d685f22c72a5e16d7383d333fb89db278711b2b8c794e29a91eaa-filelists.xml.gz [Recv failure: Connection reset by peer] (http://ftp.polytechnic.edu.na/pub/fedora/linux/updates/23/x86_64/repodata/af3c46471b1d685f22c72a5e16d7383d333fb89db278711b2b8c794e29a91eaa-filelists.xml.gz).
2.Tried curl download without the ssl certificate verification and it worked
i.e
curl -k -O https://www.ftp.saix.net/linux/distributions/fedora/linux/updates/23/x86_64/repodata/repomd.xml
Solution
Disable ssl certificate verification during the yum update i.e
sudo yum --verbose update --setopt "sslverify=0" -y

MySQL with MAMP does not work with OSX Yosemite 10.10

[EDIT]
The last version of MAMP with the last version of OSX Yosemite works fine.
I installed the beta of Yosemite two month ago, no problem with MAMP.
With the last release of OSX, Apache and MySQL did not work.
I found a solution for Apache by using the default port 80 and renaming the file envvars to _envvars in Applications/MAMP/Library/bin but have not been able to solve the problem with MySQL.
Per the Knowledge Base at MAMP for "Apache will not start - Yosemite Beta":
Rename the file envvars located in /Applications/MAMP/Library/bin into _envvars
You can also try this workaround posted at http://community.bitnami.com/t/mysqld-doesnt-start-in-mac-os-yosemite/25153
/Applications/XAMPP/xamppfiles/xampp
Look for:
$XAMPP_ROOT/bin/mysql.server start > /dev/null &
And add unset DYLD_LIBRARY_PATH on top of it. It should look like:
unset DYLD_LIBRARY_PATH
$XAMPP_ROOT/bin/mysql.server start > /dev/null &
I hope it helps
On MAMP, I was able to get MySQL to work by editing /Applications/MAMP/bin/startMysql.sh and unsetting DYLD_LIBRARY_PATH. So the updated script looks like this:
# /bin/sh
unset DYLD_LIBRARY_PATH
/Applications/MAMP/Library/bin/mysqld_safe... etc.
It also required killing all MySQL processes previously started by MAMP.
Had same issue today (running last version of Yosemite preview), Apache of XAMPP for OSX didn't work / start. Apache's log files contained no errors.
Finally I've solved this issue by removing XAMPP for OSX and installing latest version of AMPPS (http://www.ampps.com/downloads).
I don't know what's the different or what's the initial problem causing this behaviour - but with AMPPS everything just runs fine.
Hopefully this will work also for you.
This solved my problem with mysqld and apache on XAMPP:
As you can see, Yosemite DP 5 changes a few things in its library. Probably if you’re running XAMPP server on DP5 it won’t start mysqld (MySQL database daemon).
What you should do?.
STEP 1
. Download Homebrew. Open your terminal and then type:
. . . ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
STEP 2:
. Download LIBICONV, you have to type the following lines at terminal:
. . . brew install libiconv
. . . brew link libiconv —force
STEP 3
. Download SQLITE3, you have to type the following lines at terminal:
. . . brew install sqlite3
. . . brew link sqlite3 —force
STEP 4
. Go to Applications/XAMPP/xamppfiles/lib and then delete the following files (remember to empty your trash).
. . . libsqlite3.dylib (it is an ALIAS)
. . . libsqlite3.0.8.6.dylib
. . . libiconv.2.dylib
. . . libiconv (it is an ALIAS).
STEP 5
.Restart you “manager-osx.app” then try to turn on your mysql database.
Via: http://exequielplaza.com/funstuff/xampp-dp5-yosemite-mysqlfix.html
OP question was about MAMP.
I had this issue after installing OSX Yosemite and fixing the envvars to _envvars in the bin/apache2/bin folder.
Then I was getting this socket error. So I checked the error logs for mysql and noticed this:
InnoDB: Unable to lock ./ibdata1, error: 35
InnoDB: Check that you do not already have another mysqld process
gee I love error logs.
I found the process mysqld in Activity Monitor and killed it. Restarted MAMP and bingo! It all seems to hook up now!
I have resolved the situation by changing the default Port of Apache 2.4 updated after upgrading to MAC OS Yosemite.
The file is located in: /etc/apache2/httpd.conf
Change
Listen 80
to
Listen 8080
Restart your MAC, and try to launch again MAMP Services.
I fixed this by uninstalling XAMMP and reinstalling. If you go with this approach make sure to back up any content you may have saved in the XAMPP folder.
I am also running into the same problem with MAMP.
Absolutely clueless but with the other responses pointing toward a recent update in OSX I can believe that the problem stems from here. Uninstalled and reinstalled MAMP and MySQL is the only operation able to run...Apache still hangs. Will be downloading AMPPS to see if this corrects things.
I still needed to use envars so I was able to work around this by removing the following from the file. Found some errors when launching through terminal related to this
if test "x$DYLD_LIBRARY_PATH" != "x" ; then
DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
else
DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib"
fi
export DYLD_LIBRARY_PATH
I have had the same issue and none of the above worked.
The Apache server in MAMP wouldn't work on port 80, or 8080 (The default Apache ports).
The issue is with Apache being enabled by default in Yosemite.
Either: change the Apache port in MAMP (Not preferable if you want to use the default port), or unload the launch Daemon by typing the following into the terminal:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
Edit the below file, with this command on Terminal.app:
sudo vim /Applications/XAMPP/xamppfiles/mysql/scripts/ctl.sh
On line #59, delete this:
/Applications/XAMPP/xamppfiles/xampp startmysql > /dev/null &
and put this
/Applications/XAMPP/xamppfiles/bin/mysql.server start > /dev/null &
(save the file: ESC :wq!)
Restart All Servers on XAMPP.app (manager-osx)
Just to add to this thread, for those running Bitnami MAMP I had the same issue when upgrading to Yosemite (Mampstack-5.4.28-0). I solved it by going to
Applications/Mampstack-(your version)/mysql/scripts/ctl.sh
and adding the following
MYSQL_PIDFILE = ....
unset DYLD_LIBRARY_PATH <==== Add this
MYSQL_START = ....
MYSQL spun like silk. Hope this helps someone with the same problem.
I've found this video. This works for me.
Go to MAMP in Applications
then, bin > apache2 > bin and rename 'envvars' to '_envvars'
https://www.youtube.com/watch?v=brpKAM2WXhk
Above solutions didn't work for me as I had no conflicting mysqld instances running. After check the mysql error logs in MAMP, it was obvious msqld was having all sorts of issues starting. The main error was:
[ERROR] /Applications/MAMP/Library/bin/mysqld: unknown option '--//skip-networking'
Which pointed me to an option in my.conf file. Somewhere along the line with debugging another issue I had added:
//skip-networking
As an option or I had commented it out. Removing that line allowed mysql in MAMP to start correctly.