Skip to content
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

Non-HTTP server loaded from file #141

Closed
SebastianEdwards opened this issue Aug 11, 2011 · 1 comment
Closed

Non-HTTP server loaded from file #141

SebastianEdwards opened this issue Aug 11, 2011 · 1 comment

Comments

@SebastianEdwards
Copy link

All the examples of non-HTTP/TCP servers seem to all be within self-contained files. I wanted to start these workers from a file however passing in a file path seems to cause cluster to automatically treat it as a HTTP server or similar and tries to call the 'on' and 'listenFD.bind' methods on it. Commenting out the section of code in worker.js seems to allow this to work as I would expect.

Perhaps cluster could check whether 'on' and 'listenFD.bind' methods exist before trying to call them?

app.js

setInterval(function(){
   console.log("I'm alive");
}, 2000);

server.js

var cluster = require('cluster');

var proc = cluster('./app')
  .set('workers', 4)
  .use(cluster.debug())
  .start();

Code in worker.js causing issue

// demote usr/group
  if (this.server) {
    this.server.on('listening', function(){
      var group = self.options.group;
      if (group) process.setgid(group);
      var user = self.options.user;
      if (user) process.setuid(user);
    });

    // stdin
    this.stdin.on('fd', this.server.listenFD.bind(this.server));
  }
@tj tj closed this as completed in 4a9ed21 Aug 15, 2011
@tj
Copy link
Contributor

tj commented Aug 15, 2011

thanks for the report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants