1

I'm trying to run a server automatically when my vagrant box boots.

Similar to start screen detached in a vagrant box with ssh, how?, except I'm trying to do it with a provisioning script set to run: "always".

I'm doing something like this: nohup screen -S server -mL -d bash -c 'start-my-server.sh'.

The server starts fine, and if I would have done this within the shell, I could switch to the server with screen -r server.

When I go in after with vagrant ssh, it doesn't find any screens...I'm assuming this is because its not the same shell session.

Is there anyway to get a hold of that screen session?

Edit Forgot to mention that I had prefixed the screen command with nohup

Community
  • 1
  • 1
blockhead
  • 9,655
  • 3
  • 43
  • 69
  • possible duplicate of [Run automatically program on startup under linux ubuntu](http://stackoverflow.com/questions/7221757/run-automatically-program-on-startup-under-linux-ubuntu) – Paulo Scardine Feb 04 '15 at 20:59
  • have you heard of `nohup`? I believe you should see the screen running from a second session unless the first was running under another user. What `ps` tells you? – Paulo Scardine Feb 04 '15 at 21:01
  • I did try `nohup`, but that didn't seem to help. – blockhead Feb 04 '15 at 21:05
  • @PauloScardine please explain what that question has to do with mine. – blockhead Feb 04 '15 at 21:06
  • Sorry, I misunderstood your question, but check this one: http://stackoverflow.com/questions/16513513/how-can-i-force-vagrant-ssh-to-do-pseudo-tty-allocation – Paulo Scardine Feb 04 '15 at 21:07
  • @PauloScardine, the question I linked to, links to that question as well, so obviously I saw it. I'm trying to run this in the context of a vagrant provision, not an ssh command on my running vagrant instance. – blockhead Feb 04 '15 at 21:09
  • Ok...figured it out...vagrant runs the user as root, so it _was_ a different user. – blockhead Feb 04 '15 at 21:11

1 Answers1

1

The answer is that vagrant provision was running as a privileged user, and therefore I couldn't see the screen logging in as the vagrant user.

blockhead
  • 9,655
  • 3
  • 43
  • 69