1

I am trying to have vagrant install all that is needed for nodejs to run properly. Then after doing a 'nohup grunt server &' on the root folder of the node project I was expecting for the server to be up listening at port 3030 but it's not.

If right after provisioning I do vagrant ssh grunt server &

all works as it should. It's only when the provisioner runs it that it doesn't work.

Here's part of my Vagrantfile:

git clone https://github.com/airbnb/rendr.git
cd /home/temp/rendr/examples/00_simple/
npm install
cp -rf /home/temp/rendr/examples/00_simple/ /home/website/nodejs/rendr-try1
cd /home/website/nodejs/rendr-try1/00_simple
nohup grunt server &

So it definitely seems to be related to the provisioner not running in a terminal, but is there any easy way to get this running without using something like upstart ?

4

1 回答 1

7

好的,发现了这一点。

事实证明,任何想要保持运行的进程都必须被适当地守护。为了做到这一点,必须分离标准输入、标准输出和标准错误。

我在做

"nohup grunt server &" 

通过 grunt 启动 node.js 将其替换为:

"nohup grunt server 0<&- &>/dev/null &" 

完美运行

于 2013-11-05T15:52:17.197 回答