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.
Asked
Active
Viewed 2.0k times
2 Answers
45
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
- 551
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,640
- 17
- 26