lau / vagrant_elixir

Vagrant setup for a VM for Elixir development
Apache License 2.0
33 stars 11 forks source link

phoenix reload issues #1

Open lau opened 8 years ago

lau commented 8 years ago

I have had issues with Vagrant and Phoenix live reloads and changes to Javascript and CSS. So far I have not found out the cause, but just want to warn people about it. If anyone has had good/bad experiences with using this with Phoenix, please do tell.

lau commented 8 years ago

It turns out that inotify (which Phoenix uses) is not compatible with the directory sharing that vagrant uses in /vagrant.

cloud8421 commented 8 years ago

In a similar situation, I've used a polling script. Even trying with Guest additions didn't work.

philwade commented 7 years ago

Ran into these issues with my own personal vagrant/phoenix setup and it's a bit of a rabbit hole. Virtualbox says you should disable sendfile on your webserver for shared directories (see: https://www.vagrantup.com/docs/synced-folders/virtualbox.html), but Cowboy doesn't have this option, although there is some discussion about adding it here: https://github.com/ninenines/cowboy/issues/812

The issue is supposed to go away if you use NFS shared folders and some goofy options (see: https://github.com/mitchellh/vagrant/issues/4204). I haven't played with it much, just thought I'd add some additional context. I may end up trying out a docker setup since this makes working with brunch/css/js basically impossible. :man_shrugging:

thehunmonkgroup commented 6 years ago

I'm happy to report that I've solved this issue in my own installation, details below:

Another option for working around the sendfile issue is to use NFS for shared directories. This is the config I've used that's working well:

config.vm.synced_folder "/host/path/", "/guest/path/", type: "nfs", :mount_options => ['nolock,vers=3,udp,noatime,actimeo=1']

Great! One problem solved, however, the inotify functionality that Phoenix uses for live reload detection doesn't work with NFS...

To resolve that issue, install this vagrant plugin: https://github.com/mhallin/vagrant-notify-forwarder

After those two and a reload of the guest machine, live reload works perfectly