1

pm2 start ngrok http 5000 This is the command I've entered. But it didn't work out as I wanted.

Please help me to use ngrok using PM2.

If you use ngrk http 5000, you will be able to use it until the terminal is closed. It works normally.

I want to use this in PM2.

My operating system is Window10 Node-Js.

Thank you.

LMNOPss
  • 11
  • 2

3 Answers3

3

download / extract to same folder

https://ngrok.com/download

then run following

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'

run

pm2 startup 
pm2 save 

to persist across reboots

johndpope
  • 5,035
  • 2
  • 41
  • 43
0

I think you need to use -- to pass arguments to ngrok when you run it with pm2:

pm2 start ngrok -- http 5000

Related question: How to pass arguments to app using pm2?

vitkarpov
  • 399
  • 2
  • 8
  • [1]: https://i.stack.imgur.com/Mr4CT.png but ngrok stoped ;.; pls help me i am webpage source => C:\ ngrok install -g – LMNOPss May 18 '20 at 10:56
0

So, first install Ngrok with NPM npm install ngrok -g
https://www.npmjs.com/package/ngrok

Then configure your Ngrok.yml acordingly.

After that, you can run your pm2 like in this example.

pm2 start npm --name app -- run develop 
pm2 start npm --name ngrok -- run ngrok --all
pm2 monit

So pm2 start npm --name ngrok -- run ngrok --all runes, the yml configuration for all.

enter image description here

Pablo Palacios
  • 2,767
  • 20
  • 37