Questions tagged [pm2]
PM2 is a CLI process manager for Node.js applications with a built-in load balancer
2,065
questions
0
votes
1
answer
15
views
Use pm2 with nextjs in docker image
I have a docker image that I am trying to use pm2 on. For some reason I am getting a 404 error if I run it with the following command in my dockerfile. Am I calling this correctly?
CMD ["...
0
votes
0
answers
12
views
pm2 log not showing response status code and response time
When checking pm2 log, why some api request log as follows
POST /api/getdetail - - ms - -
Response status code is missing also -- ms -- indicating no response time. Is this related to express ...
0
votes
2
answers
36
views
Error: ENOSPC: no space left on device, write pm2 server
I am not able to identify what is causing my ec2 disk space to reach 100% of capacity.
I have a script which deletes files in tmp folder.But still randomly sometimes my disk capacity reaches 100%.
I ...
1
vote
1
answer
35
views
npm: pm2-windows-startup not working properly
I want my application to automatically restart on Windows reboot. I am using the pm2-windows-startup package provided by the npm. But, I am having an issue. When I restart the remote server and enter ...
0
votes
1
answer
15
views
How to start a PM2 process using a virtual python environment with variables and disable pm2 logging
I am trying to start a python script in pm2 with a a variable.
Without a variable, I would run:
pm2 start --name myapp /home/user/myapp/start.py --interpreter ~/myapp_venv/bin/python3
The python ...
0
votes
3
answers
22
views
Where do log files locate in pm2 in sudo mode
I'm new to PM2 and ubuntu-related issues.
I'm running an app using sudo with the syntax sudo pm2 start app.js --time.
However, when I tried to check the files in $HOME/.pm2/logs/app-error.log, I ...
0
votes
1
answer
39
views
Environment variable not visible in Python application started from pm2
I'm using a server for the first time. It has Ubuntu 18.04.
I've never worked with that OS, but after some guides I managed to get my code working, except for the environment variable.
In ~/.bashrc at ...
0
votes
0
answers
23
views
Node app crashes after closing the terminal, even using pm2
I'm doing web automation by using Puppeteer with NodeJS. It works fine when I'm logged in to the terminal. I'm using ec2 instance Ubuntu 22 server.
But when I'm exit out of the terminal and then try ...
0
votes
1
answer
18
views
How to force pm2 to restart after every hour? cli method
I am using PM2 to keep my node.js apps running.
Is there any way to have PM2 restart my app every 1 hour with CLI method?
0
votes
0
answers
11
views
Nginx configuration for 2 apps on same domain, one static, one SSR
I have 2 apps.
App1 is a ReactJS single page app and I want it as a homepage at www.mydomain.com
App2 has a nodejs back-end exposing graphql APIs + a ReactJs front-end and I want this app's homepage ...
0
votes
1
answer
29
views
How come my Discord bot (NodeJS) doesn't go online after a system reboot on a Raspberry Pi 4, with pm2?
I am trying to host a Discord bot on a Raspberry Pi. I have gotten everything to work and I have a bot running on it. I also made it so the bot restarts on a system reboot. The bot logs in perfectly. ...
0
votes
1
answer
23
views
How to use pm2 start npm in a specific directory?
Is there a CLI tag for running pm2 start npm -- start in a specific directory? I looked around but could find an answer.
On the other hand, when I run pm2 without npm, I can specify which directory I ...
0
votes
0
answers
18
views
nginx + pm2 : every morning nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
I have a VPS with Ubuntu 20.04, nginx and pm2. Two web apps are configured using nginx for two subdomains. e.g. sub1.domain.com and sub2.domain.com
The VPS service provider has pre-installed Webuzo ...
0
votes
0
answers
33
views
Pm2 trigger email if service down
I am running a php script to output the server, cronJobs, and processes. If I do pm2 stop server and run the script it shoots an email with details of which service is stopped, everything is working ...
0
votes
0
answers
33
views
typeorm `Data truncated for column` error in nestjs pm2
I am using pm2 to keep nestjs running.
I have created 2 folders on the server.
One receives the changed ts file using git, builds it, and converts it to js.
And the other one is run as pm2, and the ...
0
votes
1
answer
54
views
PM2 is catching errors before they reach 'uncaught Exception' in Node.js
Hey Guys,
I am running a discordbot with Discord.js in Node.js. My goal is to run it via pm2 on a Linux Ubuntu Server.
I want to build a cleanup process before exiting the program on uncaught ...
0
votes
0
answers
17
views
PM2 Process delete automatically on exit from terminal
.pm2/dump.pm2 gets cleared after closing the terminal.
npm i -g pm2
pm2 start --name myapp src/server.js
pm2 save
pm2 startup
sudo env PATH=$PATH:/home/user/.nvm/versions/node/v16.15.0/bin /home/user/....
0
votes
1
answer
14
views
Advice on managing a MERN app in production
I have a full-stack app I've developed myself using the MERN stack (+ socket.io and meilisearch). It has been deployed for a few months and started crashing intermittently with no discernible pattern. ...
0
votes
0
answers
13
views
Deployment app - Everything works but HTTP is not working if I try without home WIFI
I created a react app on my computer and trying to deploy it on the server (Hostinger)
Installed Nginx, node, and pm2 on the server.
2-1. Upload the build folder and API(Express)
App-- Client(react-...
0
votes
0
answers
39
views
Can pm2 cluster mode assign different process.env to worker as nodejs cluster.fork([env]) does?
If not using pm2, my cluster.fork will assign different env for works, like following
if (cluster.isMaster) {
x = [1, 2, 3, 4];
for (let i = 0; i < 4; i++) {
cluster.fork({x:x[i]}); //set ...
0
votes
0
answers
8
views
How to merge env variables for PM2 commands along with existing env variables?
I have a pm2 configuration json file like below, is there any way to merge the env variable while executing the pm2 commands.
like pm2 restart --env dev with different port number.
{
"apps&...
0
votes
0
answers
19
views
Change the pm2 path to the correct environment
My pm2 logs keep telling me that there is no file called credentials.json in the path /home/ubuntu. This is correct since the file is stored in /home/ubuntu/apps/myapp/credentials.json.
When the ...
0
votes
0
answers
15
views
Detect pm2 process complete programmatically
I've that following pm2 start code, it runs a basic process in 1.js which takes 5 seconds to complete, but after it completed how can I detect that the process is finished in my main js file to take ...
0
votes
0
answers
10
views
trying to log ip via nginx reverse proxy
I have Nginx serving a node.js and react application that communicate with each other. I deployed to my cloud with pm2.
I am storing IPs that are connecting and instead of the client's IP, I get the ...
0
votes
0
answers
9
views
Aws PM2 Server Data Requests
Our aws server sending more data as weexpected.and we want to learn data traffic and logs all sending data from server .how can we do that ?
0
votes
1
answer
28
views
How to run 2 application with different node version using pm2
I am following microservice architecture for my application.
I have 7 microservices few running on the node and a few are on python and go. 2 of the microservice have multiple instances (i.e. running ...
-1
votes
1
answer
29
views
Prevent "EADDRINUSE" with pm2?
I am about to switch my node application server from phusion passenger to pm2.
Most of the ports of my apps are set to 3001. With passenger that's never been a problem, but with pm2 ports collide (...
0
votes
0
answers
16
views
How to configure nextJS build serve with pm2 json config?
I wanted to start nextJS build using pm2 where I want to write the pm2 config in json format. How can I achieve this?
"name": "myApp",
"script": "...
-1
votes
1
answer
28
views
Email Notification in pm2-health
I am using pm2-health in NodeJs. It is sending email notification when there are run-time errors. But it is not sending email notifications when facing application level errors.
e.g. If hitting any ...
0
votes
0
answers
39
views
Gateway timeout when adding username and password
I'm trying to add basic authentication to a nginx reverse proxy which is in front of a nuxtjs app.
I've configured nginx as so
server {
server_name <url>;
auth_basic "...
0
votes
1
answer
41
views
Python script throws module not found error in pm2 but works in cmd
I want to demonise a python script with pm2 that worked before.
I've created a venv with Python 3.6.8. I installed all modules that are required and tryed the script via console, which works.
But if I ...
0
votes
0
answers
38
views
502 Bad Gateway On page reload Nginx error on running NodeJS website built with ejs
When I first visit the website, it loads correctly. but on refresh, it gives me the error 502 Bad Gateway Nginx/1.14.0 (Ubuntu). I am deploying a simple e-commerce site with nodejs. I am using vps ...
0
votes
0
answers
16
views
pm2 .env.enc variables does not exist
I have a server running on pm2. But the problem is that when I run the server with node it detects the .env.enc variables without problems. When I start it from pm2 it does not find these variables, ...
0
votes
0
answers
14
views
Low active handles crashes server node.js
I have a server node.js in typescript, I use typerom, mysql2 driver and express. I'm using pm2 too.
When I make posts, using transitions, I believe an increase in actives handles is normal.
await ...
1
vote
0
answers
11
views
PM2 auto turned off all apps in windwos server 2016
It has been working for 2 months. but this morning my vision is gone.
App
Windows server 2016
PM2 version = 5.2.0
There is also no error log before shutdown. I saw all the log files in /users//.pm2.
(...
0
votes
1
answer
70
views
How can I add a response header when running a SPA in Azure Web Apps using PM2
I have a React SPA which runs in Azure Web Apps, Node stack (Node 16 LTS), via the startup command:
pm2 serve /home/site/wwwroot --no-daemon --spa
I would like to add a response header (specifically, ...
0
votes
1
answer
23
views
How to run PM2 in a distroless image
I want to run node application with pm2 in distroless image.
As it do not have any shell inside it.
0
votes
0
answers
27
views
pm2 cluster calling a specific instance? And one request handled by all instances simultaneously
I am having a small problem with an application ran by pm2 cluster mode. Normally everything is working fine, but due to the logic of my application and recently switching to cluster mode i am now ...
0
votes
1
answer
43
views
Modify the "exec cwd" path of the process -PM2
I have multiple processes that run on the server.
Each of the processes is placed in it's own directory.
All of them are controlled by PM2
Each process is supposed to have config and ecosystem files ...
0
votes
0
answers
21
views
Activating cron restarts on pm2 after reboot
Currently, I have this ecosystem.config.js file setup:
module.exports = {
apps: [
{
name: 'Bot',
script: `./src/index.js`,
watch: false,
...
0
votes
1
answer
44
views
Missing one .js resource from .nuxt/dist/client folder after yarn build
I'm trying to deploy my Nuxt project using apache and pm2.
The nuxt project will be the front-end, and it has a backend api that is on a different domain.
I got the virtual host setup fine, I can ...
0
votes
1
answer
115
views
Is Next js Backend multithreaded by default?
Currently i'm starting my project with build-in Node js sever inside Next js , using next start command , but I'm not sure that if it has multithreading enabled .
My question is , Do you recommend ...
-1
votes
2
answers
68
views
How to get the first element of a array?
The command pm2 id <name> returns an array (e.g [2]), how would I get the first element from the array?
I want to save the output in APP_ID=$(pm2 id <name>) so APP_ID ends up being 2
0
votes
0
answers
19
views
Why do my API endpoints return 404 only when I use pm2? (EC2, Node, nginx, React)
I'm running a MERN stack application on an EC2 Ubuntu instance with an nginx proxy. If I start the server using npm start or node app.js my frontend React app can call the API successfully. However if ...
0
votes
0
answers
38
views
Remote Debugging Node.js in Docker with VSCode
I'm having trouble connecting to a remote container's node.js app in VSCode for debugging.
Here's my setup:
1. Docker
I have port 9331 exposed in my docker setup as shown here:
> docker container ...
0
votes
1
answer
16
views
forever-monitor fails when run with pm2 on digitalocean droplet - Target script does not exist
I have a node app with forever-monitor.
When I run it locally it works correctly.
When I run it manually on a digitalocean droplet with node app-fm.js it also run correctly.
However, when It tries to ...
0
votes
0
answers
95
views
WebSocket is closed before the connection is established. NextJS+socket.io+PM2
This is my first experience with socket. My project stack: NextJS(v10), express, socket.io, socket.io-client, freeice
Everything works fine on localhost. The problem arose when I decided to test on a ...
0
votes
1
answer
16
views
dotenv not updating on the React frontend with pm2
I have deployed my MERN app on aws ec2 ubuntu and I am using dotenv to load my environment variables, using pm2 for the server and also using nginx.
In the server I am trying to load the values on my ....
0
votes
0
answers
15
views
PM2.io Logging Only Real-Time. No Historic Logs
I'm working on an Express/Node application using PM2.io to monitor. Application is deployed on Heroku. For the life of me, I can't get the historic logs to work. Real-time Logs do work.
Below is how ...
0
votes
0
answers
80
views
Error [ERR_REQUIRE_ESM] in nuxtjs 2 while deploying with ec2
Getting error of Error [ERR_REQUIRE_ESM] while deploying nuxtjs 2 application.
Scripts:
"build": "nuxt build",
"start": "./node_modules/pm2/bin/pm2 start pm2.config....