首页 > 解决方案 > 我想知道如何在 PM2 中使用 ngrok

问题描述

pm2 start ngrok http 5000 这是我输入的命令。但它并没有如我所愿。

请帮助我通过 PM2 使用 ngrok。

如果您使用 ngrk http 5000,您将可以使用它,直到终端关闭。它工作正常。

我想在 PM2 中使用它。

我的操作系统是 Window10 Node-Js。

谢谢你。

标签: node.jspm2ngrok

解决方案


下载/解压到同一个文件夹

https://ngrok.com/download

然后运行以下

pm2 start pm2-ngrok.yaml

pm2-ngrok.yaml

    apps:
      - name : 'ngrok'
        script: './ngrok'
        args: 'http --hostname=YOURSUBDOMAINHERE.ngrok.io PORTHERE'
        instances: '1'
        autorestart: true
        max_restarts: 10
        max_memory_restart: '500M'
        watch : false
        error_file: 'err-prod.log'
        out_file: 'out-prod.log'
        log_file: 'combined-prod.log'

pm2 startup 
pm2 save 

在重新启动后持续存在


推荐阅读