Last Updated: February 25, 2016
·
1.892K
· pix-art

Run a command on every "vagrant up"

So today I had this issue where a service was dependant on a folder which gets mounted after the box is started. So the service failed since it got started with the box and before the mount.

One thing that is done after the mounting has complete is your provisioning. So what I did was the following:

config.vm.provision :shell, :inline => "service supervisor stop && service supervisor start", run: "always"

A simple but effective way to restart a service when your box is fully functional, by adding run: "Always" every time your box is started this will run.

More info: https://docs.vagrantup.com/v2/provisioning/basic_usage.html

All my tips have been moved to my blog www.pix-art.be so come check it out!