Closed nicbet closed 7 years ago
start_port(Path, Cwd) ->
Path1 = filename:absname(Path),
Args = ["-c", "inotifywait $0 $@ & PID=$!; read a; kill $PID",
"-m", "-e", "modify", "-e", "close_write", "-e", "moved_to",
"-e", "create", "-e", "delete",
"-e", "attrib", "--quiet", "-r", Path1],
erlang:open_port({spawn_executable, os:find_executable("sh")},
[stream, exit_status, {line, 16384}, {args, Args}, {cd, Cwd}]).
I added modify
flag, please check
Yes with the modify flag, live reload does work (I had modified deps/fs/src/sys/inotifywait.erl
on my machine before posting the issue).
Looking at the output of inotifywait -m
:
web/templates/page/index.html.eex ATTRIB
web/templates/page/index.html.eex MODIFY
web/templates/page/index.html.eex OPEN
web/templates/page/index.html.eex ACCESS
web/templates/page/index.html.eex CLOSE_NOWRITE,CLOSE
web/templates/page/index.html.eex ATTRIB
web/templates/page/index.html.eex MODIFY
web/templates/page/index.html.eex MODIFY
web/templates/page/index.html.eex ATTRIB
web/templates/page/index.html.eex MODIFY
web/templates/page/index.html.eex MODIFY
web/templates/page/index.html.eex OPEN
web/templates/page/index.html.eex ACCESS
web/templates/page/index.html.eex CLOSE_NOWRITE,CLOSE
But you removed for some reason the ATTRIB and DELETE in your snippet
My apologies the snippet is based on 0.9.2
which is installed as a dep as part of the latest phoenix release.
Ah ok, so you ask me to draft a new release?
Ok, I added modified
event in Linux backed.
@5HT, it appears that fs ~> 2.12
does correctly enable live reload on Docker for Mac containers (via listening to ATTRIB
) without the need to add MODIFY
.
Looks like upstream phoenix_livereload
has recently rolled back to fs 0.9.1
due to rebar
issues, which as a side-effect ended up causing the live reload regression I'm seeing. https://github.com/phoenixframework/phoenix_live_reload/commit/e54bf6fb301436797ff589e0b76a047bb79b6870
Since fs 2.12.x
fixes the live reload issue with Docker containers on Docker for Mac that is present in 0.9.2
, I think the best course of action is to close this issue and wait for upstream phoenix_livereload
to move back to 2.12.x
.
Ok, let me know if there is any problem 👍
When running Phoenix framework inside Docker on a Mac OS X host, live reload functionality does not work. Similar issues have been reported with WebPack/React (https://forums.docker.com/t/docker-for-mac-inotify-events-only-working-from-vim/18772/9)
According to https://github.com/docker/for-mac/issues/896 and https://github.com/docker/for-mac/issues/681#issuecomment-248409203 it appears that Docker for Mac does not currently translate modification FSEvents to WRITE inotify events.
Modifying https://github.com/synrc/fs/blob/master/src/sys/inotifywait.erl#L11 and adding the modify event to the list of watched events fixes this issue and enables proper functioning of live reload on file edits with Elixir/Phoenix applications executing in Docker on Mac.
Tested on: