-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no automatic restart when using boot2docker docker volume #419
Comments
When I use boot2docker with my branch off of library/node, when I try to use nodemon /path/to/app --watch, the cpu goes nuts like it is constantly restarting, although I can't verify. I tried -L, but it also caused the CPU to go nuts. I changed to pm2 for now, but it has 2-3 seconds of delay before it restarts. Still, better than nothing. |
+1 this happens to me as well with a mounted volume on boot2docker (OSX + VirtualBox). |
I'm marking as "help wanted" - I don't have the infrastructure to even begin testing and debugging this. I'm sure it's linked to clocks being out of whack somehow, but can't replicate myself with simple tests. |
@remy if I can help you in any way, just let me know what I should do. |
@tanis2000 if you can pull the project inside of your virtual machine. I'd start by trying to discover why Really you want to get a handle on what's causing the issue in the first place. I usually console log the crap out of the code when I'm spelunking for errors. |
still not seeing an automatic restart with a volume mounted nodejs project in b2d |
Remy, thanks for nodemon. Did you close this issue because you resolved it? Or did you not have enough helpful feedback to fix? We've been experiencing the same problems as mentioned above. |
No, it looks like it was closed by mistake in the associated PR. I'll reopen and ask for help (from you lot!). |
If anyone wants to push a Docker image that I can test and debug this with – I'd be grateful. |
👍 same problem here |
@olalonde then same question to you: "[do you have] a Docker image that I can test and debug this with – I'd be grateful.". |
I will make one if someone else doesn't. I can't get to it until tonight though, which is why I had not yet replied. Assuming Ubuntu 12.04 is ok unless I hear otherwise. A faster solution would be to use vagrant. If you have vagrant and virtualbox, you can install a VM with
Then install node/npm and nodemon. Place a node file in a shared resource (such as /vagrant) and you should find these problems to be easy to reproduce. I'm not sure about docker as I no longer use docker for development (because of this issue, and because I use MacOSX and the boot to docker image causes CPU and sleep problems for my little Macbook Air.) It still affects my work in Vagrant and seems to have the same results. BTW, PM2 suffers a similar fate now in Vagrant. It simply fails to restart at all. |
Ok, I just made a test but can't push it to Github at the moment. Install boot2docker. Run Put all the following files in the same directory (e.g.
FROM node:0.10-slim
RUN mkdir /app
WORKDIR /app
CMD ["./node_modules/nodemon/bin/nodemon.js", "index.js"]
console.log(new Date());
{
"name": "testnodemon",
"devDependencies": {
"nodemon": "^1.2.1"
}
} Once, you have those files, run the following commands. npm install;
docker build -t testnodemon .;
docker run -v $(pwd):/app testnodemon; Edit You can use the following to get a shell in the container: docker run -i -t -v $(pwd):/app testnodemon /bin/bash;
root@762c18df76ee:/app# mount | grep app
none on /app type vboxsf (rw,nodev,relatime) |
The problem I believe is that Anyways, I hope you can come up with something better :) |
It is such a problem to resolve that we started running node locally with a remote Cassandra DB (since C* would be the only service in docker.) |
Another solution would be to watch files normally on the host and whenever a file changes, write to |
I just submitted a PR with the solution I posted above. It's not elegant, but it's simple and it works. Basically, nodemon needs to run on the host with the nodemon --local and the VM/container can listen for file change events by using the nodemon --remote index.js The local nodemon communicates with the remote one by toggling a file called |
Though the command is slightly different, so fork the code logic. This will still fall back to alternative method if find isn't available. Ref #419
Can you try the development version of nodemon that I've pushed? It contains a lot of other tweaks, but the main thing I've changed is it'll use find instead of fs.watchFile (which I think uses the broken IO notify...). To install: npm install -g nodemon@dev Can someone quickly give me an idea of whether that works or not? I tried it myself, but I'm still pretty new to docker so wasn't quite sure of what I was doing... |
(it should be [email protected]) |
Nope, okay, I'm pretty sure [email protected] farts and makes a mess in docker. Anyone else want to confirm that's cool, otherwise I'll take this as a fail. |
I can confirm for myself at least using |
@remy Thanks for your care on this issue. I've changed my workflow and haven't used this feature in some time. If other people have reported success with |
|
@pencilcheck you should also be wary of the number of files its watching. |
@remy |
In a VM -L is still needed it seems but I have switched to a different van that setup NFS instead of vboxfs, now it runs much much quieter but unfortunately writing speed is not as responsive as native |
|
Nothing of the above worked for me, so I ended up creating a small bash-script that starts my servers, restarts the pm2 instance inside docker from the host OS and tails docker logs. To avoid zombie processes, I'vce included a trap that kills the docker processes started by docker-compose
|
I was chasing this issue for a while. Nodemon was catching the change no problem but node never received the signal to terminate. I was looking through the nodemon source and saw that there was an issue with child processes and as a result it was using psTree to get to the children. The docker image I was using (fedora) didn't come with PS pre installed and so nodemon was using a fallback to pull the process that wasn't working for me. Installing the 'procps' package in the dockerbuild got it working for me. Hope this helps someone. |
So, what's the final solution and how to, to get nodemon watching for changes in Mac OS X -> Boot2Docker -> Docker Container? It's possible or not? There's some documentation/README.md/Wiki? @remy |
@thalesfsp It looks as though there is a few issues possibly causing this. @Omnomios has done some next level bug chasing and found something. For me, I simply had to explicitly set --watch. |
The best way I have found to have filesystem notifications visible within the container was as follows: It may not be the most efficient or most elegant way, but this way was transparent to users of the container. No additional script needs to be run. |
I have similar solution to @Omnomios. #!/bin/bash
image=$(docker ps | grep <container_name> | cut -d " " -f1 )
docker exec -t $image pm2 restart server and hooked it up to gulp.task('watch-backend', function() {
webpack(backendConfig).watch(100, function(err, stats) {
onBuild(err, stats)
restartServer()
})
})
var exec = require('child_process').exec
function restartServer() {
exec('./restart-container.sh', function(err, stdout, stderr) {
if (stdout) {
console.log('stdout: ' + stdout)
}
if (stderr) {
console.log('stderr: ' + stderr)
}
if (err !== null) {
console.log('exec error: ' + err)
}
})
} It has been working pretty well for me. |
I cannot figure out how to get this working either. Shelling into the container and touching a file triggers nodemon...doing the same thing from osx doesn't do anything. |
whoops...I missed the need for |
|
I am using |
Using a barebones security distro and was having this issue. @Omnomios solution installing |
Only |
Has anyone found a better solution, more official fix (maybe without any parameter)t o this |
@jcwolf have you tried the solution that worked for me? Here's a snippet of my Dockerfile
|
@mshick would you be able to add this to the FAQ? Sounds like you've solved a problem that many people run in to! Thanks in advance |
a simple patch would be to change the defaultConnectionProperties.properties inside the jar file. oracle.jdbc.timezoneAsRegion=false defaultConnectionProperties.properties file path: oracle.jdbc,you can find it from ojdbc6.jar. |
nodemon doesn't seem to restart node when using a docker volume, or in this case a boot2docker ( os x -> virtualbox -> docker) volume. nodemon starts okay, but then fails to restart node when a watched file has been modified in the shared OS X volume.
nodemon -L
causes restarts at least once a second even when no files have changed - way too frequently.forever -w
seems to work just fine. That seems like the best workaround for now.output of dump:
The text was updated successfully, but these errors were encountered: