Closed djui closed 13 years ago
and it 100% works with just node? (no spark)
Yes. When I do the following change, everything works (no sparks involved):
/*
cluster(server)
.in('development')
.set('workers', 1)
.use(cluster.logger('logs', 'debug'))
.use(cluster.debug())
.listen(8001)
.in('production')
.use(cluster.logger('logs'))
.listen(80)
.in('all')
.use(cluster.stats())
.use(cluster.pidfiles('pids'))
.use(cluster.cli())
.use(cluster.repl(8002));
*/
server.listen(8001);
» curl http://127.0.0.1:8001
<html></html>
If you want to have a look, the code I use is this: https://github.com/djui/kgist/tree/cluster
one think you might want to try, since often requiring the server in the master file ends up creating a bunch of db connections etc that are not ideal, is using cluster('./myapp')
etc, which expects you to export the server via module.exports. this was nothing in that file is executed in master, only in the workers
Tried that before as recommended but didn't help. But found the cause: When using the REPL feature of cluster one must not use+start the Node REPL. removing the repl.start()
fixed it. Is that worth mentioning in the readme? Or a bug?
what happened? you had your own repl and cluster's repl?
Yes, I just added the cluster example code by copy and paste not being aware of that I still had my own repl require
line still in the source file, including a start()
on it. That conflicts with cluster without an error.
I tried to port my express server to use cluster instead of spark2, but after starting it no response ever gets an answer (times out). I tried to follow https://github.com/LearnBoost/cluster/blob/master/examples/express.js but no change.
I have no idea how to show you some debug info besides the following:
... and...
The configuration is as follows: