起因:最近在docker里面安装了一个whistle服务,但是吧 总挂。想着用pm2同时启动多个。
mac上直接输入
pm2 start "whistle run --port 8899" --name "1" & pm2 start "whistle run --port 9988" --name "2"
这样就可以了 但是在docker 中就不好使。哭
数据发送中...
2022-02-23T11:01:55: PM2 log: Launching in no daemon mode
2022-02-23T11:01:55: PM2 log: Launching in no daemon mode
2022-02-23T11:01:55: PM2 log: Launching in no daemon mode
2022-02-23T11:01:55: PM2 log: Launching in no daemon mode
2022-02-23T11:01:55: PM2 log: Launching in no daemon mode
2022-02-23T11:01:55: PM2 log: App [7799:0] starting in -fork mode-
2022-02-23T11:01:55: PM2 log: App [7799:0] online
[i] whistle@2.9.1 started
[i] 1. use your device to visit the following URL list, gets the IP of the URL you can access:
http://127.0.0.1:7799/
http://10.198.192.206:7799/
Note: If all the above URLs are unable to access, check the firewall settings
For help see https://github.com/avwo/whistle
[i] 2. set the HTTP proxy on your device with the above IP & PORT(7799)
[i] 3. use Chrome to visit http://local.whistlejs.com/ to get started
Press [Ctrl+C] to stop whistle...
实际上呢 在docker里面或者电脑上启动多个pm2需要配置相应额环境变量
例如:
Multiple PM2 on the same server
The client and daemon communicates via socket files available in $HOME/.pm2/[pub.sock|rpc.sock]
You can start multiple PM2 instances by changing the PM2_HOME environmnent variable.
$ PM2_HOME='.pm2' pm2 start echo.js --name="echo-node-1"
$ PM2_HOME='.pm3' pm2 start echo.js --name="echo-node-2"
This will start two different PM2 instances. To list processes managed by each different instances do:
$ PM2_HOME='.pm2' pm2 list
$ PM2_HOME='.pm3' pm2 list
docker里面一样 用pm2-runtime就可以了
|