How to start a process in background every time I do vagrant up

2,552 views
Skip to first unread message

Martin Rubi

unread,
Jun 10, 2015, 7:52:14 AM6/10/15
to vagra...@googlegroups.com
Hi there,

I'm trying to start a process in the VM every time I do 'vagrant up' on an Ubuntu 14.x VM.
I have the following:

Vagrantfile:

Vagrant.configure(2) do |config|
   # ...
   config.vm.provision "up", type: "shell", run: "always", path: 'provision_up.sh'
end

provision_up.sh :

cd /home/vagrant/src/la-poderosa/grunt
nohup grunt > /dev/null 2>&1 &

It does work if I do 'vagrant ssh' and call provision_up.sh by hand, but it does not when I do 'vagrant halt' and then 'vagrant up'.
Could it be related to vagrant up using root instead of vagrant user? I so, how can I solve it?

I'm not a linux expert so any pointers will be very appreciated.
Thanks !
Martin

Alvaro Miranda Aguilera

unread,
Jun 10, 2015, 8:24:50 AM6/10/15
to vagra...@googlegroups.com
hello

I suggest the following change:


config.vm.provision "up", type: "shell", run: "always", inline: 'bash
/vagrant/provision_up.sh &'

I use that and works fine for me.

Alvaro.
> --
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vagrant-up+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Martin Rubi

unread,
Jun 10, 2015, 8:46:15 AM6/10/15
to vagra...@googlegroups.com
Hi Alvaro,

thanks for your answer!

It didn't work. Could it be related with not having a terminal allocated, o using the root user? Any ideas if there is any log I can read to get more info?

Thanks!
Martin

Alvaro Miranda Aguilera

unread,
Jun 10, 2015, 5:53:57 PM6/10/15
to vagra...@googlegroups.com
On Thu, Jun 11, 2015 at 12:46 AM, Martin Rubi <marti...@gmail.com> wrote:
>> cd /home/vagrant/src/la-poderosa/grunt
>> nohup grunt > /dev/null 2>&1 &

Hello martin

I may be due the script?

I think the nohup is failing

I thik this: nohup grunt > /dev/null 2>&1 &

Should be:

nohup ./grunt > /dev/null 2>&1 &

So my complete suggestion will be:

pushd cd /home/vagrant/src/la-poderosa/grunt ; nohup ./grunt > /dev/null 2>&1 &

hope this helps.

Alvaro.
Reply all
Reply to author
Forward
0 new messages