Thanks. I did not know that. daemon.start(fs.openSync()) seems to work as well, but of course something guaranteed would be nicer. Is there a supported method of being able to start a node application from the init process?
On Feb 11, 6:23 pm, Ben Noordhuis <i...@bnoordhuis.nl> wrote: > On Sat, Feb 11, 2012 at 03:21, Cory Mintz <cory.p.mi...@gmail.com> wrote: > > I have been using the node v0.4.X branch in production along with > > daemon.node (https://github.com/indexzero/daemon.node) to run node > > apps from init scripts for a few months now. I recently tried to > > upgrade to v0.6.10 and noticed that my application would run but > > didn't appear to be doing anything. After digging in, I narrowed it > > down to http.get() specifically. After get() was called none of the > > callbacks are ever called. I reduced it down to a pretty straight > > forward example: > > > var daemon = require('daemon'); > > var fs = require('fs'); > > var http = require('http'); > > > fs.open('test.log', 'w+', function (err, fd) { > > > daemon.start(fd); > > > var options = { > > host: 'www.google.com', > > port: 80, > > path: '/index.html' > > }; > > > console.log('Making request'); > > http.get(options, function(res) { > > console.log('Got response: ' + res.statusCode); > > }).on('error', function(e) { > > console.log('Got error: ' + e.message); > > }); > > > }); > > > When this code is run, "Making request" is written to test.log, but > > neither the callback or the error event are ever called. The > > application will continue to run forever though and has to be killed > > manually. While it's possible that it is daemon.node's fault, I feel > > like is unlikely since all it does is fork the process and redirect > > the standard streams. And 'Making request' is written to the log, > > which is after the fork. > > > I am testing on CentOS 5.3 > > > Has anyone else experienced problems after forking a node > > application? > > Node is not fork-safe (something that's been pointed out to the > daemon.node maintainers). > > Your example may work if you fork before calling fs.open() but there > are no guarantees. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en