Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell provisioning fails to exit #1553

Closed
axelfontaine opened this issue Apr 7, 2013 · 4 comments

Comments

@axelfontaine
Copy link

commented Apr 7, 2013

Host OS: Win7 x64, Vagrant 1.1.5
Guest OS: http://cloud-images.ubuntu.com/vagrant/quantal/current/quantal-server-cloudimg-amd64-vagrant-disk1.box

Using vagrant provision with shell provisioning, when I start a Java process with threads waiting for input (embedded Jetty server), the ssh session never closes.

The process is started like this: nohup java -cp my.jar my.MainClass arg1 arg2 &

It is then properly started in the background, and the next shell provisioned command executes. Yet, the vagrant provision command never returns.

Workaround: adding pkill ssh at the end of the shell provisioning command list and ignoring the stacktrace.

Cheers
Axel

@axelfontaine

This comment has been minimized.

Copy link
Author

commented Apr 11, 2013

OK, I found a real solution.
It turns out whatever process that wants to stay running has to be properly daemonized. In order to do this one must detach stdin, stdout and stderr.

In my case this meant replacing

nohup start.sh &

with

nohup ./start.sh 0<&- &>/dev/null &

Hope this helps someone else with a similar issue. Not sure if this could be simplified within Vagrant or not. (Autodisconnect of all standard in & outputs?)

@mitchellh

This comment has been minimized.

Copy link
Member

commented Apr 11, 2013

Ah! Interesting. I'm not sure, but I'd love to know if this could be simplified in some way. Let me know if you (or anyone else) comes up with anything.

@mitchellh mitchellh closed this Apr 11, 2013

@haknick

This comment has been minimized.

Copy link

commented Nov 5, 2013

WOW, been wasting time with this since yesterday.
I was doing "nohup grunt server &" to start node.js through grunt
Replacing it with:
"nohup grunt server 0<&- &>/dev/null &" works perfectly
Thanks a lot.

@shafi-codez

This comment has been minimized.

Copy link

commented Apr 28, 2015

This is great solution for nohup.

Thanks !

ghost pushed a commit to t-my/spbl.org that referenced this issue Jul 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.