CompileDaemon icon indicating copy to clipboard operation
CompileDaemon copied to clipboard

Reload not working on OSX

Open paologf-mb opened this issue 5 years ago • 13 comments

I'm setting up a project in Go following this guide https://levelup.gitconnected.com/how-to-live-reload-code-for-golang-and-docker-without-third-parties-ee90721ef641 , on Linux it works fine. Using it from mac when I change a file from my editor, the file into the container change but CompileDaemon doesn't recognise the change and doesn't rebuild. If I enter the container and save the changed file, CompileDaemon rebuild.

DOCKER FILE

FROM golang:latest

WORKDIR /go/src

DockerCompose

version: '3'
services:
  app:
    build:
      context: .
    volumes:
      - ".:/go/"
    container_name: golang_app
    command: bash -c "go get github.com/githubnemo/CompileDaemon && CompileDaemon -command="./app""
    ports:
      - "8080:8080"
    tty: true
    depends_on:
      - db

VERSIONs

OSX Catalina 10.15.2
Docker version 19.03.5 ( Using Docker Desktop application)

paologf-mb avatar Mar 04 '20 12:03 paologf-mb

Here the code example repository https://github.com/paologf-mb/go-docker-compiledaemon

paologf-mb avatar Mar 05 '20 09:03 paologf-mb

Any help?

paologf-mb avatar Mar 10 '20 13:03 paologf-mb

@paologf-mb Did you try it with go 1.12?

funktionslust avatar Mar 12 '20 14:03 funktionslust

Same as #44 I suspect its how the container sends events to the host due to the difference in file systems and their synchronization. Sometimes it works fine and sometimes it stops working altogether. Removing large folders like vendor and .git helped the rebuilds. Giving more resources helped as well, but it still occurs from time to time

yuraxdrumz avatar Mar 12 '20 15:03 yuraxdrumz

is it related to this post? https://www.reddit.com/r/golang/comments/c7gtzm/go_modules_docker_and_hotreload_problems/

pycckuu avatar Apr 26 '20 14:04 pycckuu

In my case, it was Docker issue. After reinstallation of Docker, everything worker fine. Thanks!

pycckuu avatar Apr 28 '20 12:04 pycckuu

@pycckuu I tried reinstalling docker but it didnt work, plus I have tried it over 10 MacBooks at work and same result for everyone, reload works several times and afterwards doesn't recognize changes.

yuraxdrumz avatar Jul 05 '20 08:07 yuraxdrumz

Sadly I have no macs available so it is hard for me to debug this but I doubt there is anything I can actively do at this point. It is either fsnotify/fsnotify that has issues or the implementation of the bind mount between MacOS host and the container.

githubnemo avatar Nov 09 '20 22:11 githubnemo

Thanks to @HurSungYun, CompileDaemon now supports -polling=true which switches from FS notifications to active polling for changes. While this is neither instant (notifications are delayed by the polling rate) nor resource friendly (always looking instead of being event driven) it is a workaround to help get people back to work. I strongly discourage you from using this in any production environment.

githubnemo avatar Nov 29 '20 11:11 githubnemo

@githubnemo It would be great if warnings are documented in READMD.md. Can I update it?

Btw, I believe using hot-reload daemon for production is not a good practice in itself, isn't it?

HurSungYun avatar Nov 29 '20 11:11 HurSungYun

oh you already updated it. nevermind XD

HurSungYun avatar Nov 29 '20 11:11 HurSungYun

@githubnemo It would be great if warnings are documented in READMD.md. Can I update it? oh you already updated it. nevermind XD

Yep but thanks anyway :)

Btw, I believe using hot-reload daemon for production is not a good practice in itself, isn't it?

I have nothing against using fsnotify based hot-reload but using polling should be discouraged as it is quite wasteful and should never become a default or habit just because there's a bug somewhere.

(But you are right of course, normally you would expect your artefacts to be stable and not need hot-reloading once shipped to production, as such I would see it as bad practice to use hot-reloading in production.)

githubnemo avatar Nov 29 '20 11:11 githubnemo

I started having this problem with the latest versions of docker-desktop. One thing I noticed was the default behavior of enabling the Use gRPC FUSE for file sharing flag in the preferences. Turning this off, and restarting my machine, seemed to resolve the issue.

Screen Shot 2020-12-05 at 10 02 43 PM

Perhaps others will have luck with toggling this option off?

justinpage avatar Dec 06 '20 06:12 justinpage