Comments (5)
Good catch.
Repro steps:
Dockerfile:
FROM gliderlabs/alpine:3.1
RUN apk-install nodejs
RUN npm install -g nodemon
RUN mkdir -p /src
VOLUME /src
WORKDIR /src
ADD . /src
EXPOSE 1337
CMD ["nodemon", "server.js"]
Commands:
> docker build -t node-test .
> docker run --rm -v $(pwd):/src -p 1337:1337 node-test
Output after making a single change to server.js
on OS X:
Server running at http://0.0.0.0:1337/
20 May 19:10:08 - [nodemon] restarting due to changes...
20 May 19:10:08 - [nodemon] starting `node server.js`
Server running at http://0.0.0.0:1337/
20 May 19:10:08 - [nodemon] restarting due to changes...
20 May 19:10:08 - [nodemon] starting `node server.js`
Server running at http://0.0.0.0:1337/
I'm not sure what the cause is yet, but I'll poke around.
from docker-osx-dev.
Further investigation: this is not caused by the vagrant-gatling-rsync plugin. If I stop automatic syncing and just manually sync a single file change using vagrant rsync
, it still causes nodemon to restart twice. Looking further...
from docker-osx-dev.
OK, by enabling verbose logging in nodemon with the -V
flag, it turns out there are a few things happening here:
20 May 19:29:12 - [nodemon] files triggering change check: .server.js.8ajJIp
20 May 19:29:12 - [nodemon] changes after filters (before/after): 1/0
20 May 19:29:12 - [nodemon] files triggering change check: .server.js.8ajJIp
20 May 19:29:12 - [nodemon] changes after filters (before/after): 1/0
20 May 19:29:12 - [nodemon] files triggering change check: .server.js.8ajJIp
20 May 19:29:12 - [nodemon] changes after filters (before/after): 1/0
20 May 19:29:12 - [nodemon] files triggering change check: .server.js.8ajJIp
20 May 19:29:12 - [nodemon] changes after filters (before/after): 1/0
20 May 19:29:12 - [nodemon] files triggering change check: .server.js.8ajJIp
20 May 19:29:12 - [nodemon] changes after filters (before/after): 1/0
20 May 19:29:12 - [nodemon] files triggering change check: .server.js.8ajJIp
20 May 19:29:12 - [nodemon] changes after filters (before/after): 1/0
20 May 19:29:12 - [nodemon] files triggering change check: server.js
20 May 19:29:12 - [nodemon] matched rule: **/*.*
20 May 19:29:12 - [nodemon] changes after filters (before/after): 1/1
20 May 19:29:12 - [nodemon] restarting due to changes...
20 May 19:29:12 - [nodemon] server.js
20 May 19:29:12 - [nodemon] files triggering change check: src
20 May 19:29:12 - [nodemon] changes after filters (before/after): 1/0
20 May 19:29:12 - [nodemon] starting `node server.js`
20 May 19:29:12 - [nodemon] child pid: 75
20 May 19:29:12 - [nodemon] watching 3 files
Server running at http://0.0.0.0:1337/
20 May 19:29:12 - [nodemon] files triggering change check: server.js
20 May 19:29:12 - [nodemon] matched rule: **/*.*
20 May 19:29:12 - [nodemon] changes after filters (before/after): 1/1
20 May 19:29:12 - [nodemon] restarting due to changes...
20 May 19:29:12 - [nodemon] server.js
20 May 19:29:12 - [nodemon] starting `node server.js`
20 May 19:29:12 - [nodemon] child pid: 83
20 May 19:29:12 - [nodemon] watching 3 files
Server running at http://0.0.0.0:1337/
So three things are triggering a restart:
- A change to
server.js
. This the only change we care about. - A change to
.server.js.8ajJIp
. Is this some temporary file used by sublime or vim? - A change to the
src
folder. Perhaps rsync is updating the timestamps on this folder?
The easiest solution for now is probably to increase the nodemon delay flag so it doesn't restart immediately after every change, but waits a little while for a batch of them. In the meantime, I'll see if there are some rsync flags that will fix issues 2 and 3.
from docker-osx-dev.
OK, I just added several rsync settings to the Vagrantfile
that may improve things:
--omit-dir-times
: don't update timestamps on folders. This way, the root folder of the project doesn't get updated for every single file change that happens within it.--inplace
: by default, rsync creates a temporary file and then merges it into the original file. Theinplace
flag tells it to skip the temporary file thing and replace the original file.--whole-file
: replace the entire file at once instead of applying diffs.
Now when I make a single change, I see the following:
20 May 20:25:00 - [nodemon] restarting due to changes...
20 May 20:25:00 - [nodemon] restarting due to changes...
20 May 20:25:00 - [nodemon] restarting due to changes...
20 May 20:25:00 - [nodemon] starting `node server.js`
Server running at http://0.0.0.0:1337/
So nodemon is still detecting multiple changes, but only actually restarting once, which is an improvement. With verbose logging, it looks like it's detecting multiple changes to the same file (server.js
), so perhaps rsync is still updating it in stages, despite the --whole-file
flag. Not sure what I can do about that, but as long as you only get one restart, it shouldn't matter, right?
To try out the new version, run:
> docker-osx-dev stop
> vagrant destroy
> rm -f Vagrantfile
> docker-osx-dev init
> docker-osx-dev start
from docker-osx-dev.
Based on the latest updates, I'm closing this issue. Please re-open if you're still having problems.
from docker-osx-dev.
Related Issues (20)
- Where did it sync my files? HOT 7
- case issue with Caskroom HOT 3
- "Connection refused" running docker-osx-dev with docker-machine HOT 1
- docker-osx-dev install: returns "tar: write error: No space left on device" HOT 4
- I had an error 'greadlink: command not found' HOT 5
- No performance increase on 1.11 HOT 2
- /usr/local/bin/docker-osx-dev: line 797: /usr/local/bin/rsync: cannot execute binary file
- OSX rsync permission denied on file change HOT 1
- Couldn't connect to Docker daemon.. HOT 1
- OS X Docker Beta compatibility HOT 12
- docker-osx-dev crashes if current path has a space in it HOT 1
- Constant "Password:" prompts HOT 2
- Halt immediately if dependencies are missing HOT 1
- Running docker-osx-dev changes file owner on my host HOT 11
- Ignore shared folders HOT 1
- Bug introduced with 1a1d6370f6fa75159ace63ce9a8204e0c8c10631: tar: could not chdir to '/engagement-chat' HOT 4
- SSL certificate error on compose up HOT 2
- Error when trying to init docker-osx-dev HOT 5
- It deletes every file created inside docker HOT 1
- Drupal 7 performance boost not improving
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-osx-dev.