Phoenix: Live reload doesn't work

Created on 9 Aug 2015  Â·  16Comments  Â·  Source: phoenixframework/phoenix

Hi
I've tried to get phoenix up and running today with this
http://www.phoenixframework.org/docs/up-and-running
but live reload doesn't work.
Phoenix version 0.16.1

Most helpful comment

@chrismccord How would you add the source code inside the VM volume with vagrant? Doesn't that defeat the purpose? I'm having the same issue with the live reload with different languages. I've read your solution before, so I guess you're right.

All 16 comments

Can you provide more information? OS, browser console errors, server errors? Also make sure the host you are accessing from in the browser matches the :url host in dev.exs

On Aug 9, 2015, at 8:26 AM, Roman [email protected] wrote:

Hi
I've tried to get phoenix up and running today with this
http://www.phoenixframework.org/docs/up-and-running
but live reload doesn't work.
Phoenix version 0.16.1

—
Reply to this email directly or view it on GitHub.

this is from the file dec.exs

config :hello, Hello.Endpoint,
  http: [port: 4000],
  debug_errors: true,
  code_reloader: true,
  cache_static_lookup: false,
  watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin"]]

# Watch static and templates for browser reloading.
config :hello, Hello.Endpoint,
  live_reload: [
    patterns: [
      ~r{priv/static/.*(js|css|png|jpeg|jpg|gif)$},
      ~r{web/views/.*(ex)$},
      ~r{web/templates/.*(eex)$}
    ]
  ]

i run mix phoenix.server
then point browser to localhost:4000
There is an error here

[error] backend port not found: :inotifywait

mix phoenix.server
Compiled web/views/page_view.ex
Generated hello app
[info] Running Hello.Endpoint with Cowboy on http://localhost:4000
[warning] the :size option when configuring Hello.Repo is deprecated, please use :pool_size instead
[info] GET /
[debug] Processing by Hello.PageController.index/2
  Parameters: %{"format" => "html"}
  Pipelines: [:browser]
[info] Sent 200 in 650ms
[error] backend port not found: :inotifywait

09 Aug 18:49:53 - info: compiled 5 files into 2 files, copied 3 in 8021ms

then i edit web/templates/page/index.html.eex save and page is not reloading...

This is the issue:

[error] backend port not found: :inotifywait

Please see the backend installation docs here
https://github.com/phoenixframework/phoenix_live_reload#backends

Reopen if you have issues. Thanks

@chrismccord I am having an issue with live reload as well.

Here is the console output

[info] Running HelloPhoenix.Endpoint with Cowboy using http on port 4000
26 May 04:59:41 - info: compiled 5 files into 2 files, copied 3 in 3 sec
Setting up watches.  Beware: since -r was given, this may take a while!
Watches established.
[info] GET /
[debug] Processing by HelloPhoenix.PageController.index/2
  Parameters: %{}
  Pipelines: [:browser]
[info] Sent 200 in 162ms

When I save a file I am not seeing anything recognising the change.

I am using Ubuntu 14.04 LTS in a VM using Vagrant and Virtual box.

Any ideas?

the most likely culprit is you are editing source files on a shared host volume with the VM severing the app. Mix cannot cope with this because of mismatched ctimes/mtimes. The solution is to move the source inside the VM volume

@chrismccord How would you add the source code inside the VM volume with vagrant? Doesn't that defeat the purpose? I'm having the same issue with the live reload with different languages. I've read your solution before, so I guess you're right.

@fellz
[error] backend port not found: :inotifywait is due to the inotifty-tool not installed in your system.

Just install it the required package depending upon your OS.
https://github.com/rvoicilas/inotify-tools/wiki

I hope this might help to someone who didn't read documentation properly :)

Is live_reload something that does not work with symlinked directories?

Yes, it should. As Elixir symlinks by default but I guess it may depend on the OS. Which OS are you on?

OSX 10.11.6

The setup I'm going for here is very unconventional, but is structured as follows:

  • I have a phoenix app
  • I have an angular app
  • I've symlinked the built assets directory of angular to a directory in my phoenix app
  • I want to kick off my phoenix server and have it watch that assets directory
  • When I build my angular app, I want the phoenix server to see that the built files have changed and reload the app in the browser.

Presently that last bullet is not what is happening and I can't figure out why.

Phoenix doesn't watch your assets directory, it watches the directory where your artifacts are written to, usually in priv/static.

Right,

So what I've done is in the priv/static/js directory I've created another directory called "legacy" which is a directory symlinked to my angular projects directory where built assets are stored. What I was hoping is that live reloading would occur when assets change in that symlinked folder, but I'm not experiencing that.

How do I completely disable inotifywait? This issue is causing a dockerized phoenix container I have to crash with a prod version of my project. Is there any way just to turn it off completely? Since the source and content are loaded in the container for a prod release, the content will not change, so I don't need any hot reloads. I would think that this is a dev-only feature that should not be required...

@twajjo Unless you changed things, a prod release build does not even include the code for inotifywait access and reloading of files, so I think your post may be missing some information there?

Also, it should not crash, I run even dev things in docker with no problem whatsoever, so again it seems some information is missing? ^.^

I thought so. It seems the issue was in my Dockerfile. Always take the docker documentation with a grain of salt and examples provided by co-workers with a whole 5-lb. bag of it. Thanks.

I'm having this issue, with a docker container. I'm on OSX, here's what I've tested that makes me confused -

I volume map my code to the container.
The startup has no errors in it. See log later in the post.
I make a change on my system using VIM, doesn't reload.
I go into the docker container directly and make a change to a file, doesn't reload.
After a while (a few minutes) it seems to recompile one file.
Any ideas? Confirmed I have inotify-tools (alpine linux).

Startup log:

web_1        | ==> myapp
web_1        | Compiling 5 files (.ex)
web_1        | Generated myapp app
web_1        | ==> myapp_web
web_1        | Compiling 15 files (.ex)
web_1        | Generated myapp_web app
web_1        | [info] Running RegenWeb.Endpoint with Cowboy using http://0.0.0.0:4000
web_1        | 16:50:32 - info: compiling
web_1        | 16:50:33 - info: compiled 6 files into 2 files, copied 4 in 15.4 sec

EDIT: I'm playing with this more, and found out that it's just because I have a phx.new --umbrella generated app, and live_reload isn't included (of course) in the non my app_web app - which makes sense, I just expected changes to in myapp to get noticed and recompiled by live_reload or something.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

josevalim picture josevalim  Â·  3Comments

fertapric picture fertapric  Â·  3Comments

tcoopman picture tcoopman  Â·  3Comments

GPrimola picture GPrimola  Â·  3Comments

blisscs picture blisscs  Â·  4Comments