29

I want Vagrant to start the Play server in the /vagrant/ folder every time I do vagrant up. Putting @reboot on the crontab doesn't work because the script runs before the /vagrant/ folder is connected.

wrongusername
  • 447
  • 2
  • 5
  • 7

2 Answers2

44

I found using a seperate vagrant provisioner with the option run : "always" a lot easier, eg:

config.vm.provision :shell, path: "yourStartUp.sh", run: "always", privileged: false

See https://docs.vagrantup.com/v2/provisioning/shell.html for full doc.

culmat
  • 541
  • 1
  • 4
  • 2
16

Instead of using crontab, have you tried using Upstart?

Vagrant emits a "vagrant-mounted" event when the shared folder is mounted, so you could create an upstart conf file, say /etc/init/play.conf, to run when that event is emitted:

description "Play server"
start on vagrant-mounted

pre-start script
    [ "$MOUNTPOINT" == "/vagrant" ] || stop
end script

... rest of config file for starting Play server ...
billyw
  • 1,552
  • 15
  • 25