Deploy node app with http-server and forever

你。 提交于 2019-12-03 08:49:37

You can set the options using that code. Just use the available flags after the end of your command. For example:

forever start ./node_modules/http-server/bin/http-server -p 80 -d false

I had the same issue. Found a node.js script that can run shell commands and used it to run the http-server command along with options.

example of node.js script named 'startserver.js':

var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { sys.puts(stdout) }
exec("sudo http-server -a ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com -p 80", puts);

Then you can run it using forever:

forever start startserver.js

This worked with me

First get path of http-server like this

which http-server

for example you will get "/usr/bin/http-server"

then after that write the forever followed by http-server path and your app path

forever start /usr/bin/http-server /your/app/path

Best regards.

Mattia Costamagna

Try this:

$ forever start $(which http-server) -p 8000 -d false

you can add any parameters after forever start $(which http-server)

$(which http-server): return the http-server path
-p 8000 : port 8000, change it to any port number
-d: Show directory listings

Browse to your directory that contains your files And from the command line type: forever start -c http-server . -p your_port_number Example: forever start -c http-server -p 8000

In this way, the port 8000 will forever point to the html files in your directory.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!