I have a node app in a container and for dev mode the code is mounted in through local volume. Common practise, right.
But now I switched over from the old boot2docker to latest docker-machine and the auto restart has stopped working. I have to restart service manually to load code changes.
Any ideas who to fix with this ?
[root@c11c978e6430 src]# nodemon --dump
[nodemon] 1.8.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
--------------
node: v0.10.36
nodemon: 1.8.1
command: node /usr/bin/nodemon --dump
cwd: /src
OS: linux x64
--------------
{ run: false,
system: { cwd: '/src' },
required: false,
dirs: [ '/src' ],
timeout: 1000,
options:
{ dump: true,
ignore:
[ '.git',
'node_modules',
'bower_components',
'.sass-cache',
re: /\.git|node_modules|bower_components|\.sass\-cache/ ],
watch: [ '*.*', re: /.*\..*/ ],
ignoreRoot: [ '.git', 'node_modules', 'bower_components', '.sass-cache' ],
restartable: 'rs',
colours: true,
execMap: { py: 'python', rb: 'ruby' },
stdin: true,
runOnChangeOnly: false,
verbose: false,
stdout: true,
execOptions:
{ script: 'index.js',
exec: 'node',
args: [],
scriptPosition: 0,
nodeArgs: undefined,
ext: 'js,json',
env: {},
execArgs: [] },
monitor:
[ '*.*',
'!/src/.git/**/*',
'!/src/node_modules/**/*',
'!bower_components',
'!.sass-cache' ] },
load: [Function],
reset: [Function: reset],
lastStarted: 0,
loaded: [],
watchInterval: null,
command:
{ raw: { executable: 'node', args: [ 'index.js' ] },
string: 'node index.js' } }
--------------
got same problem. My host system is MacOS Yosemit 10.10.5. I'm running nodemon on official image https://hub.docker.com/r/library/node/ sources https://github.com/nodejs/docker-node/blob/master/5.1/Dockerfile
great! I have found solution nodemon --legacy-watch
It is super slow with that flag (but it works)
This works for me aswell! Thanks @hyzhak
Is there any way to not rely on --legacy-watch? It does work around the issue, but it's super slow.
Any insights on what the root cause for this is?
@gvilarino seems like it turns polling on in chokidar. Here is a snippet from the chokidar readme.
usePolling (default: false). Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU utilization, consider setting this to false. It is typically necessary to set this to true to successfully watch files over a network, and it may be necessary to successfully watch files in other non-standard situations. Setting to true explicitly on OS X overrides the useFsEvents default.
Seems like docker fits here.
it may be necessary to successfully watch files in other non-standard situations.
@LucioFranco precisely, I'm relying on this for a docker-based local dev env (OS/X).
Just unsure why it can't work without the flag (always wanting to learn) and possibly provide a root solution.
It is true that outside of linux-based systems, --legacy-watch will be needed until docker no longer relies on a VM for running its daemon. It does seem that with MSFT allowing bash/native linux binaries to run natively on Windows as a subsystem, and docker relying on OS/X's hypervisor for running natively as well this could be solved, but I know really little about both Chokidar, Linux or Docker's internals.
I was wondering if anyone has been able to have nodemon working properly on mounted drives without using --legacy-watch
I guess this doesn't work because inotify (linux file system watcher) doesn't work from inside a virtual machine.
It would be nice if we could work around this by using something like this:
Serverfault - Vagrant shared folder and file change events
I can confirm this works with the pseudo-native docker for mac client; I guess this is closable.
https://docker-sync.io/ works much better for me now, don't need of --legacy-watch flag anymore.
@hyzhak Thanks. It works for me as well 馃憤
Inotify works with Docker for Mac. With Docker for Windows it still doesn't work.
for me it works with -L flag:
nodemon -L run.js
also earlier mentioned:
nodemon --legacy-watch run.js
Host: OS X El Capitan 10.11.6 and arc linux in docker
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3
--legacy-watch isn't working for me. I'm using version 1.18.10.
@goodoldneon You could set some environment variables for Chokidar.
docker-compose.yml example:
services:
myservice:
environment:
CHOKIDAR_USEPOLLING: 'true'
CHOKIDAR_INTERVAL: 300
@PieterScheffers
No effect 馃檨
great! I have found solution
nodemon --legacy-watch
Thank you very much this worked for me
Most helpful comment
great! I have found solution
nodemon --legacy-watch