PM2 not launching nodejs application on localhost - node.js

PM2 is not launching the application on the localhost. Without PM2 i start my application with npm start. i have tried pm2 start npm -- start but i get an unexpected token error in the logs.
$ pm2 logs
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
C:\Users\fssykes.pm2\pm2.log last 15 lines:
PM2 | 2019-05-16T11:31:05: PM2 log: App [npm:7] online
PM2 | 2019-05-16T11:31:05: PM2 log: App [npm:7] exited with code [1] via signal [SIGINT]
PM2 | 2019-05-16T11:31:05: PM2 log: App [npm:7] starting in -fork mode-
PM2 | 2019-05-16T11:31:05: PM2 log: App [npm:7] online
PM2 | 2019-05-16T11:31:06: PM2 log: App [npm:7] exited with code [1] via signal [SIGINT]
PM2 | 2019-05-16T11:31:06: PM2 log: App [npm:7] starting in -fork mode-
PM2 | 2019-05-16T11:31:06: PM2 log: App [npm:7] online
PM2 | 2019-05-16T11:31:06: PM2 log: App [npm:7] exited with code [1] via signal [SIGINT]
PM2 | 2019-05-16T11:31:06: PM2 log: App [npm:7] starting in -fork mode-
PM2 | 2019-05-16T11:31:06: PM2 log: App [npm:7] online
PM2 | 2019-05-16T11:31:06: PM2 log: App [npm:7] exited with code [1] via signal [SIGINT]
PM2 | 2019-05-16T11:31:06: PM2 log: App [npm:7] starting in -fork mode-
PM2 | 2019-05-16T11:31:06: PM2 log: App [npm:7] online
PM2 | 2019-05-16T11:31:06: PM2 log: App [npm:7] exited with code [1] via signal [SIGINT]
PM2 | 2019-05-16T11:31:06: PM2 log: Script C:\PROGRAM FILES\NODEJS\NPM.CMD had too many unstable restarts (16). Stopped. "errored"
C:\Users\fssykes.pm2\logs\npm-out.log last 15 lines:
C:\Users\fssykes.pm2\logs\npm-error.log last 15 lines:
7|npm | C:\PROGRAM FILES\NODEJS\NPM.CMD:1
7|npm | (function (exports, require, module, __filename, __dirname) { :: Created by npm, please don't edit manually.
7|npm | ^
7|npm |
7|npm | SyntaxError: Unexpected token :
7|npm | at new Script (vm.js:80:7)
7|npm | at createScript (vm.js:274:10)
7|npm | at Object.runInThisContext (vm.js:326:10)
7|npm | at Module._compile (internal/modules/cjs/loader.js:664:28)
7|npm | at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
7|npm | at Module.load (internal/modules/cjs/loader.js:600:32)
7|npm | at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
7|npm | at Function.Module._load (internal/modules/cjs/loader.js:531:3)
7|npm | at Function._load (C:\Users\fssykes\AppData\Roaming\npm\node_modules\pm2\node_modules#pm2\io\build\main\metrics\httpMetrics.js:172:43)
7|npm | at Object. (C:\Users\fssykes\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:27:21)

Related

How to tell to pm2 to ignore all errors in scripts locpated at node_modules and subfolders?

I am testing an APP under server enviroment:
Use of aaPanel or btPanel under ubuntu
Use of pm2 module
The app is running but restart on error
I am using custom error managment and log functions
I want pm2 just ignore all console.log(error) and errors ocurred in scripts located at node_modules and subfolder
Anny idea?
Thanks for your time and for any help
This is a example of some error log from pm2:
2021-03-12T01:52:51: PM2 log: App [MyApp] exited with code [0] via signal [SIGINT]
And this is a example of error in out log from pm2:
Error: /www/wwwroot/apps/MyApp/1.0.0.2/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at Module.Hook._require.Module.require (/www/server/nvm/versions/node/v14.16.0/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/www/wwwroot/apps/MyApp/1.0.0.2/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
This is a log from console pm2 console in aaPanel or btPanel:
2021-03-12T00:05:50: PM2 log: ===============================================================================
2021-03-12T00:05:50: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
2021-03-12T00:05:50: PM2 log: Time : Fri Mar 12 2021 00:05:50 GMT+0000 (Coordinated Universal Time)
2021-03-12T00:05:50: PM2 log: PM2 version : 4.5.5
2021-03-12T00:05:50: PM2 log: Node.js version : 14.16.0
2021-03-12T00:05:50: PM2 log: Current arch : x64
2021-03-12T00:05:50: PM2 log: PM2 home : /root/.pm2
2021-03-12T00:05:50: PM2 log: PM2 PID file : /root/.pm2/pm2.pid
2021-03-12T00:05:50: PM2 log: RPC socket file : /root/.pm2/rpc.sock
2021-03-12T00:05:50: PM2 log: BUS socket file : /root/.pm2/pub.sock
2021-03-12T00:05:50: PM2 log: Application log path : /root/.pm2/logs
2021-03-12T00:05:50: PM2 log: Worker Interval : 30000
2021-03-12T00:05:50: PM2 log: Process dump file : /root/.pm2/dump.pm2
2021-03-12T00:05:50: PM2 log: Concurrent actions : 2
2021-03-12T00:05:50: PM2 log: SIGTERM timeout : 1600
2021-03-12T00:05:50: PM2 log: ===============================================================================
2021-03-12T00:20:11: PM2 log: App [MyApp] starting in -fork mode-
2021-03-12T00:20:11: PM2 log: App [MyApp] online
2021-03-12T00:21:59: PM2 log: Stopping app:1.0.0.2 id:0
2021-03-12T00:21:59: PM2 log: App [MyApp] exited with code [0] via signal [SIGINT]
2021-03-12T00:21:59: PM2 log: pid=95350 msg=process killed
2021-03-12T00:22:24: PM2 log: App [MyApp] starting in -fork mode-
2021-03-12T00:22:24: PM2 log: App [MyApp] online
2021-03-12T00:40:41: PM2 log: Stopping app:MyApp id:0
2021-03-12T00:40:41: PM2 log: App [MyApp] exited with code [0] via signal [SIGINT]
2021-03-12T00:40:41: PM2 log: pid=96990 msg=process killed
Aditional Notes:
The app run flawless under local enviroment
The pm2 is the problem some awfull bad config maybe!
I run and test the app using 'nodemon index.js' all ok
I run and test the app using 'node index.js' all ok
I run and test the app using 'npm start' all ok
I run npm update all ok
I run npm audit all ok

Build folder not recognized in pm2 service

I'm running my node+react app on vps ubuntu machine using ssh.
I used nginx, pm2 for running my node js server, but when I check my logs it shows the following error:
App [server:0] starting in -fork mode-
PM2 | 2020-09-16T07:05:03: PM2 log: App [server:0] online
PM2 | 2020-09-16T07:06:18: PM2 log: Reloading logs...
PM2 | 2020-09-16T07:06:18: PM2 log: Reloading logs for process id 0
PM2 | 2020-09-16T07:38:58: PM2 log: Stopping app:server id:0
PM2 | 2020-09-16T07:38:58: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
PM2 | 2020-09-16T07:38:58: PM2 log: pid=6888 msg=process killed
PM2 | 2020-09-16T07:38:58: PM2 log: App [server:0] starting in -fork mode-
PM2 | 2020-09-16T07:38:58: PM2 log: App [server:0] online
0|server | Error: ENOENT: no such file or directory, stat '/root/repos/IRS-Ecommerce/IRS-
Ecommerce/build/index.html'
/root/.pm2/logs/server-out.log last 15 lines:
0|server | Server is up and running at port : 8080
0|server | MongoDB connected successfully!
My node js server file where I'm sending my react app in response:
app.use(express.static("IRS-Ecommerce/build"));
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "IRS-Ecommerce", "build", "index.html"));
});
I've run npm build in my react app and build folder is present there, but it is showing this error that index.html is not there. I've checked the path, it is correct.
When I access public IP, my react app shows up which means it is working. But why am I seeing this error here?
/root/repos/IRS-Ecommerce/IRS- Ecommerce/build/index.html double IRS-
Ecommerce orz

Nodejs pm2 is always restarting when I reboot Ubuntu

I have an express nodejs server running in Ubuntu LTS with pm2. The server runs fine, but when I restart Ubuntu, the server is always rebooting.
I use an ecossystem.config like this:
module.exports = {
apps : [{
name: 'gTimeTracking',
script: 'index.js',
args: 'one two',
instances: 1,
autorestart: true,
watch: true,
max_memory_restart: '1G',
env: {
NODE_ENV: 'development'
},
env_production: {
NODE_ENV: 'production'
}
}]
};
I started the server with this command:
pm2 start ecosystem.config.js --env production
And with pm2 save
and I have this infinite error on Ubuntu reboot
0|gTimeTracking | Server running since: Mon Jul 01 2019 09:36:43 GMT+0200 (CEST)
PM2 | Change detected on path logs/logger-01-07-2019-09.log for app gTimeTracking - restarting
PM2 | Stopping app:gTimeTracking id:0
PM2 | App [gTimeTracking:0] exited with code [0] via signal [SIGINT]
PM2 | pid=16255 msg=process killed
PM2 | App [gTimeTracking:0] starting in -fork mode-
PM2 | App [gTimeTracking:0] online
0|gTimeTracking | Server running since: Mon Jul 01 2019 09:36:44 GMT+0200 (CEST)
PM2 | Change detected on path logs/logger-01-07-2019-09.log for app gTimeTracking - restarting
PM2 | Stopping app:gTimeTracking id:0
PM2 | App [gTimeTracking:0] exited with code [0] via signal [SIGINT]
PM2 | pid=16274 msg=process killed
PM2 | App [gTimeTracking:0] starting in -fork mode-
PM2 | App [gTimeTracking:0] online
Last time I had this problem I had to reinstall many times pm2 to relaunch the server, but now this method doesn't works and isn't an stable solution
What could be wrong?
I had to use pm2 cleardump for solve the problem with pm2 delete all and pm2 kill it didn't works for me. (I didn't have to change anything about the loggers path)

Node app stops responding after some time

I recently pushed my node js and express server to the production.
After a few days of working on the production, I realized that sometimes with no reason my server stops responding for requests.
[31/Dec/2018:09:55:39 +0000] "GET /vehicles?user_lat=52.458876&user_lng=16.9006237 HTTP/1.1" - - ms
I was looking for an answer here but the only advice I found was to debug server and find out what is causing it crashes. Unfortunately, I am not able to find out where is the problem. I added listeners to the process to find unhandled promises rejection and uncaught exception but nothing was caught.
What I also found is when the server stops responding the CPU usage is
running high. Normally it takes 1-5%, but when it hangs it is around 20%.
The next strange thing for me is the output of pm2.log file. According to it, my server often restarts but I don't understand why.
pm2.log file:
2018-12-22T10:12:10: PM2 log: pid=28427 msg=process killed
2018-12-22T10:12:10: PM2 log: App [server:0] starting in -fork mode-
2018-12-22T10:12:10: PM2 log: App [server:0] online
2018-12-24T13:33:40: PM2 log: Stopping app:server id:0
2018-12-24T13:33:40: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
2018-12-24T13:33:41: PM2 log: pid=31380 msg=process killed
2018-12-24T13:33:41: PM2 log: App [server:0] starting in -fork mode-
2018-12-24T13:33:41: PM2 log: App [server:0] online
2018-12-24T13:45:29: PM2 log: Stopping app:server id:0
2018-12-24T13:45:29: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
2018-12-24T13:45:29: PM2 log: pid=5521 msg=process killed
2018-12-24T13:45:29: PM2 log: App [server:0] starting in -fork mode-
2018-12-24T13:45:29: PM2 log: App [server:0] online
2018-12-25T03:11:40: PM2 log: Stopping app:server id:0
2018-12-25T03:11:40: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
2018-12-25T03:11:40: PM2 log: pid=6049 msg=process killed
2018-12-25T03:11:40: PM2 log: App [server:0] starting in -fork mode-
2018-12-25T03:11:40: PM2 log: App [server:0] online
2018-12-27T05:07:30: PM2 log: Stopping app:server id:0
2018-12-27T05:07:30: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
2018-12-27T05:07:30: PM2 log: pid=11531 msg=process killed
2018-12-27T05:07:30: PM2 log: App [server:0] starting in -fork mode-
2018-12-27T05:07:30: PM2 log: App [server:0] online
2018-12-29T08:08:27: PM2 log: Stopping app:server id:0
2018-12-29T08:08:27: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
2018-12-29T08:08:27: PM2 log: pid=28263 msg=process killed
2018-12-29T08:08:27: PM2 log: App [server:0] starting in -fork mode-
2018-12-29T08:08:27: PM2 log: App [server:0] online
2018-12-29T09:41:23: PM2 log: Stopping app:server id:0
2018-12-29T09:41:23: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
2018-12-29T09:41:23: PM2 log: pid=11341 msg=process killed
2018-12-29T09:41:23: PM2 log: App [server:0] starting in -fork mode-
2018-12-29T09:41:23: PM2 log: App [server:0] online
2018-12-31T10:03:33: PM2 log: Stopping app:server id:0
2018-12-31T10:03:33: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
2018-12-31T10:03:33: PM2 log: pid=12337 msg=process killed
2018-12-31T10:03:33: PM2 log: App [server:0] starting in -fork mode-
2018-12-31T10:03:33: PM2 log: App [server:0] online
2018-12-31T10:48:51: PM2 log: Stopping app:server id:0
2018-12-31T10:48:51: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
2018-12-31T10:48:51: PM2 log: pid=28552 msg=process killed
2018-12-31T10:48:51: PM2 log: App [server:0] starting in -fork mode-
2018-12-31T10:48:51: PM2 log: App [server:0] online
On the production, I use pm2 to start my server.
Here is my server.js file:
var express = require('express'),
app = express(),
port = process.env.PORT || 3000;
const morgan = require('morgan');
const routes = require('./api/routes/main_routes');
const authMiddleware = require('./api/authorization/auth');
bodyParser = require('body-parser');
app.use(morgan(':remote-addr - :remote-user [:date[clf]] ":method :url
HTTP/:http-version" :status :response-time ms'))
app.use('/images', express.static(__dirname + '/markers'));
app.use('/cars', express.static(__dirname + '/cars'));
app.use('/video', express.static(__dirname + '/video'));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(authMiddleware)
routes(app); //register the routes
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.send(err.message);
});
process.on('unhandledRejection', (reason, p) => {
console.log("Unhandled Rejection at: Promise ", p, " reason: ",
reason);
});
process.on('uncaughtException', function (exception) {
console.log(exception);
});
app.listen(port);
console.log('server started on:' + port);
And package.json file:
{
"name": "api",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "nodemon server.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"nodemon": "^1.11.0"
},
"dependencies": {
"axios": "^0.18.0",
"axios-cache-adapter": "^2.1.1",
"body-parser": "^1.17.2",
"cachios": "^2.0.0",
"cors": "^2.8.4",
"express": "^4.15.4",
"file-system": "^2.2.2",
"form-data": "^2.3.3",
"geolib": "^2.0.24",
"lodash": "^4.17.4",
"morgan": "^1.9.1",
"nodemon": "^1.18.6",
"path": "^0.12.7",
"sharp": "^0.18.4",
"websocket": "^1.0.28"
}
}
Full pm2 logs
/root/.pm2/pm2.log last 15 lines:
PM2 | 2018-12-29T09:41:23: PM2 log: Stopping app:server id:0
PM2 | 2018-12-29T09:41:23: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
PM2 | 2018-12-29T09:41:23: PM2 log: pid=11341 msg=process killed
PM2 | 2018-12-29T09:41:23: PM2 log: App [server:0] starting in -fork mode-
PM2 | 2018-12-29T09:41:23: PM2 log: App [server:0] online
PM2 | 2018-12-31T10:03:33: PM2 log: Stopping app:server id:0
PM2 | 2018-12-31T10:03:33: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
PM2 | 2018-12-31T10:03:33: PM2 log: pid=12337 msg=process killed
PM2 | 2018-12-31T10:03:33: PM2 log: App [server:0] starting in -fork mode-
PM2 | 2018-12-31T10:03:33: PM2 log: App [server:0] online
PM2 | 2018-12-31T10:48:51: PM2 log: Stopping app:server id:0
PM2 | 2018-12-31T10:48:51: PM2 log: App [server:0] exited with code [0] via signal [SIGINT]
PM2 | 2018-12-31T10:48:51: PM2 log: pid=28552 msg=process killed
PM2 | 2018-12-31T10:48:51: PM2 log: App [server:0] starting in -fork mode-
PM2 | 2018-12-31T10:48:51: PM2 log: App [server:0] online
/root/.pm2/logs/server-error.log last 15 lines:
/root/.pm2/logs/server-out.log last 15 lines:
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:27 +0000] "GET /images/marker_active.png HTTP/1.1" 200 0.849 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:27 +0000] "GET /images/marker_active.png HTTP/1.1" 200 0.667 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:27 +0000] "GET /images/marker_active.png HTTP/1.1" 200 0.567 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:28 +0000] "GET /images/marker_inactive.png HTTP/1.1" 200 1.065 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:28 +0000] "GET /images/marker_inactive.png HTTP/1.1" 200 1.302 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:28 +0000] "GET /images/marker_inactive.png HTTP/1.1" 200 0.550 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:28 +0000] "GET /images/marker_inactive.png HTTP/1.1" 200 0.566 ms
0|server | 211
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:30 +0000] "GET /vehicles?user_lat=52.14601814935841&user_lng=21.04796773265618&center_lng=21.047964502570746&center_lat=52.14602095031964 HTTP/1.1" 200 5357.940 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:31 +0000] "GET /images/marker_active.png HTTP/1.1" 200 0.624 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:31 +0000] "GET /images/marker_active.png HTTP/1.1" 200 0.613 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:31 +0000] "GET /images/marker_inactive.png HTTP/1.1" 200 0.600 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:31 +0000] "GET /images/marker_inactive.png HTTP/1.1" 200 0.520 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:31 +0000] "GET /images/marker_active.png HTTP/1.1" 200 0.567 ms
0|server | ::ffff:127.0.0.1 - - [31/Dec/2018:16:11:31 +0000] "GET /images/marker_inactive.png HTTP/1.1" 200 0.416 ms

pm2 reload ecosystem.config.js causing many restarts on application

I am experiencing problems reloading the application using the ecosystem.config.js file. When the application is started for the first time, it starts correctly, but when I refresh/reload the application using the ecosystem.config.js file, the application restarts several times causing an error.
My SO is Ubuntu Xenial, PM2 version is 3.2.2 and Node v10.13.0. The application uses the latest version from Express module (4.16.4).
If I reload the application with "pm2 reload app_name", this problem doesn't occur.
The ecosystem.config.js content:
module.exports = {
apps: [{
script: "./index.js",
instances: "max",
exec_mode: "cluster",
kill_timeout: "2000",
env: {
NODE_ENV: "development",
},
env_production: {
NODE_ENV: "production",
}
}]
}
When I run the first time:
$ pm2 reload ecosystem.config.js
[PM2][WARN] Applications index not running, starting...
[PM2] App [index] launched (2 instances)
node#ubuntu:/data/$ pm2 logs
[TAILING] Tailing last 15 lines for [all] processes (change the value with >--lines option)
/home/node/.pm2/pm2.log last 15 lines:
PM2 | 2018-11-23T13:14:30: PM2 log: App [index:0] starting in -cluster >mode-
PM2 | 2018-11-23T13:14:31: PM2 log: App [index:0] online
PM2 | 2018-11-23T13:14:31: PM2 log: App [index:1] starting in -cluster >mode-
PM2 | 2018-11-23T13:14:31: PM2 log: App [index:1] online
When I reload the application by name (ex: pm2 reload app_name), the application contiue runnig, but I see some timeouts to kill process:
PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=failed to kill - retrying in 100ms
PM2 | 2018-11-23T14:01:02: PM2 log: Process with pid 11289 still alive after 6000ms, sending it SIGKILL now...
PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=failed to kill - retrying in 100ms
PM2 | 2018-11-23T14:01:02: PM2 log: Process with pid 11296 still alive after 6000ms, sending it SIGKILL now...
PM2 | 2018-11-23T14:01:02: PM2 log: App name:index id:_old_0 disconnected
PM2 | 2018-11-23T14:01:02: PM2 log: App [index:_old_0] exited with code [0] via signal [SIGKILL]
PM2 | 2018-11-23T14:01:02: PM2 log: App name:index id:_old_1 disconnected
PM2 | 2018-11-23T14:01:02: PM2 log: App [index:_old_1] exited with code [0] via signal [SIGKILL]
PM2 | 2018-11-23T14:01:02: PM2 log: pid=11289 msg=process killed
PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=process killed
But, even though timeouts occur the application is running.
When I execute "pm2 reload ecosystem.config.js", the PM2 restart the application several times and one instance fail:
0|index | at Module.load (internal/modules/cjs/loader.js:598:32)
0|index | at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
0|index | at Function.Module._load (internal/modules/cjs/loader.js:529:3)
0|index | at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:48:21)
0|index | Error: listen EADDRINUSE :::3001
I believe the problem is related to some timeout to properly terminate the http connection of the Express module, but I'm still investigating this.
It has been fixed on the lastest PM2 version, please update:
npm install pm2#latest -g
pm2 update
Make sure you pm2 delete all and then start back your application again, it will work then when doing reload or restart

Resources