I am trying to run two executables in a node.js "scripts" section. One of them is a node.js executable (let's call it proc1
) , and the other is http-server
for serving some static assets. These are both process that run continuously. I'd like a way to manage these together, so that they start together, and can both be stopped together. I also want to be able to see the output of the cosmos
command.
I tried configuring it like this:
"scripts": {
"build": "http-server >> /dev/null &; proc1",
}
But this gives out the error:
sh: -c: line 0: syntax error near unexpected token
;' sh: -c: line 0:
;' sh: -c: line 0:
http-server &; proc1'
I tried to find a simple node.js process management solution to run this alongside, but couldn't find an appropriate one (similar to supervisor
in the Python world).
Any ideas what to do?
仅创建另一个node.js脚本来启动/停止这两个服务器。
sh: -c: line 0: syntax error near unexpected token
;' sh: -c: line 0:
;' sh: -c: line 0:
http-server &; proc1'
The error is in your shell code. Change it to
"http-server >> /dev/null & proc1",
You can't end a statement with &
, to run in the background, and also end it with ;
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.