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

Error: listen EADDRINUSE #1

Open
unlight opened this issue Dec 2, 2015 · 7 comments
Open

Error: listen EADDRINUSE #1

unlight opened this issue Dec 2, 2015 · 7 comments

Comments

@unlight
Copy link

unlight commented Dec 2, 2015

Simple sigh.js

  pipelines.build = [
    glob({ basePath: "api" }, "**/*.js"),
    process("node server.js"),
  ];

// server.js
https://github.com/openshift/origin-server/blob/master/cartridges/openshift-origin-cartridge-nodejs/usr/template/server.js

Changing files cause error:

Error: listen EADDRINUSE
    at exports._errnoException (util.js:746:11)
    at Server._listen2 (net.js:1156:14)
    at listen (net.js:1182:10)
    at net.js:1280:9
    at dns.js:85:18
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)
    at node.js:814:3

Looks like process is not killing immediatly.

I tried to subscribe on event close
https://nodejs.org/api/child_process.html#child_process_child_kill_signal
And this case no error, but server keeps previous state (strange, cannot explain)

@insidewhy
Copy link
Contributor

I haven't seen this on Linux at all, are you running it on OS X? I could try adding a restartDelay parameter for such cases?

@insidewhy
Copy link
Contributor

I could also add in listening for close, but could you explain what you mean by "server keeps previous state"?

@unlight
Copy link
Author

unlight commented Apr 20, 2016

I'm on Windows.
"server keeps previous state" means that server does no see changed files and always serve files which was resolved/compiled at first start.
Anyway, take no notice of it. I think, it is not relevant to sigh-process.
Main point - need to be sure, that proc is really killed and disposed all resources.

      log('spawn process `%s`', cmd)
      if (proc)
        proc.kill()
      if (proc) {
        proc.on('close', (code, signal) => {
           // ?
         });
      }
     // Need to be sure, that proc is really killed and disposed all resources.
      proc = spawn(splitCmd[0], splitCmd.slice(1), {
        stdio: [ process.stdin, 'pipe', process.stderr ]
      })
    }).thenReturn(events))

@unlight
Copy link
Author

unlight commented Jul 17, 2016

Any updates on this?

I got same error for process in sigh-talk

I tried dictatorship module for killing process and it works.
But it accepts port number and process.kill(pid) is used under the hood.
Problem is that proc.pid is child pid, but we need the parent pid

Can you adapt code from dictatorship to sigh-process so it will work properly on windows?

@insidewhy
Copy link
Contributor

Ah this should be easy to fix, thanks for reminding me.

@insidewhy
Copy link
Contributor

sigh-talk uses an ancient version of sigh.

@insidewhy
Copy link
Contributor

Figure it just needs waitpid

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