vagrant_elixir icon indicating copy to clipboard operation
vagrant_elixir copied to clipboard

phoenix reload issues

Open lau opened this issue 9 years ago • 4 comments

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 avatar Jan 27 '16 01:01 lau

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

lau avatar Feb 13 '16 01:02 lau

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

cloud8421 avatar Apr 21 '16 15:04 cloud8421

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:

philwade avatar Jul 07 '17 13:07 philwade

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

thehunmonkgroup avatar Nov 25 '17 21:11 thehunmonkgroup