Jasmohan Singh
Jasmohan Singh

Reputation: 61

How to see console.logs of a running nodeJs application on ubuntu 18 EC2 instance?

I am new to the node world. I created a node js rest API. When I run npm start in my local machine or in the terminal for the first time, I can see console.log() in my terminal. Now, I am running the same application on an AWS Ec2 instance with Ubuntu as os. I run npm start and serve my app on port 80. I do this via ssh and after running my server I close the ssh connection. But when I reconnect via ssh, I want to see those console.log() messages in my terminal for some purpose.

I completely understand that logging messages in the terminal is not a good idea and there can be so many alternatives. Just want to know how to access the same terminal window/result as we see when I start my application.

Upvotes: 1

Views: 3729

Answers (2)

Xuân Việt
Xuân Việt

Reputation: 65

if you are using pm2, you can try "pm2 logs"

Upvotes: 2

Mattia Rasulo
Mattia Rasulo

Reputation: 1481

So Nodemon won't work well in a production server or in any instance where you need to have the app going by itself.

Nodemon is a dev tool to enable you to restart your server during development. In a "real" vps you need to place the process in the background or it will be automatically killed when the connection times out.

Check out this YT series for a correct deploy architecture in an NGINX server with the use of pm2 and NGINX on a Red Hat server, I've personally used it more than once:

https://www.youtube.com/playlist?list=PLQlWzK5tU-gDyxC1JTpyC2avvJlt3hrIh

Upvotes: 0

Related Questions