Running NodeJs http-server forever with PM2

后端 未结 4 1230
灰色年华
灰色年华 2021-02-04 04:18

My question is about running HTTP-server in combination with PM2.

The problem I face is that:

  1. HTTP-server requires as input a folder which is the root of the
相关标签:
4条回答
  • 2021-02-04 04:24

    if we have a build generated by grunt,then go to its path and hit:

    ~/app/build/prod$ sudo pm2 start /usr/local/bin/http-server -p 8080
    

    Now check app status at localhost:8080

    0 讨论(0)
  • 2021-02-04 04:39
    pm2 start <location>/http-server --name http-server -- -p <port> -d false
    

    or

    PM2 modules it self has in-build static file to be served, which is similar to http-server https://pm2.keymetrics.io/docs/usage/expose/

    pm2 serve <path> <port>
    
    0 讨论(0)
  • 2021-02-04 04:41

    You almost had it.

    Check where http-server is located by executing:

    $ which http-server
    

    You should get something like this /usr/bin/http-server

    Then cd to the directory you want to serve files from and execute:

    $ pm2 start /usr/bin/http-server --name my-file-server -- -p 8080 -d false
    

    --name my-file-server is optional, but -- is required to pass arguments through to the http-server command.

    0 讨论(0)
  • 2021-02-04 04:41
    pm2 start 'http-server-spa websiteroot index.html 8080'
    
    0 讨论(0)
提交回复
热议问题