在哪里可以找到所有正在运行的pm2应用程序的端口? [英] Where can I find the ports of all running pm2 apps?

查看:4966
本文介绍了在哪里可以找到所有正在运行的pm2应用程序的端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台安装了PM2的服务器和10个正在运行的节点应用程序.每个应用程序都应使用不同的端口号运行.当我在服务器上安装新的应用程序时,我需要有关使用的端口的信息. 使用"pm2列表",我可以获得有关应用程序的更多信息,而不是端口.

I have a server with PM2 installed and 10 running node apps. Every App should run with a different port number. When I install a new App on the server I need the information about the used ports. With 'pm2 list' I get much info about the apps but not the port.

pm2 list

App name       │ id │ version │ mode │ pid   │ status │ restart │ uptime │ cpu  │ mem        │ user │ watching
example_name   │ 1  │ 0.0.0   │ fork │ 25651 │ online │ 0       │ 37D    │ 0%   │ 386.3 MB   │ root │ disabled

我找不到所有已使用端口的概述,并且我不相信此重要信息不是PM2提供的. 有人知道我在哪里可以看到PM2中所有已用端口的列表吗?

I can not find a overview of all used ports and I can't believe that this important information is not given by PM2. Does anyone have any idea where I see a list with all used ports in PM2?

推荐答案

是的,pm2 IMHO有点失败.仅当您在服务器上运行多个实例(站点)时. 我使用:

Yeah this is a bit of a failing with pm2 IMHO. Only when you have more than one instance (site) running on the server. I use:

ss -tnlp | grep node

然后,您可以查看pm2和端口上的pid,或者在我的情况下,您仅获得其运行目录的摘录.

You can then eyeball the pid from pm2 and the port, or in my case you get just a snippet of the directory it's running from.

OP添加了一条评论,说他将端口号添加到正在运行的节点应用程序的名称中,这可能会比较混乱,但这是个好主意.

The OP added a comment saying he added the port number into the name of the running node app, which could get messy, but is a good idea.

这篇关于在哪里可以找到所有正在运行的pm2应用程序的端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆