Can Mojito start give a "Port being used" error instead of a "throw arguments[1]; // Unhandled 'error' event"? #931

Closed
jianlin opened this Issue Jan 16, 2013 · 6 comments

Projects

None yet

4 participants

@jianlin
Contributor
jianlin commented Jan 16, 2013

Right now Mojito will report the following if the port is being used:

Can it report "Error: the port is already being used" instead? This is even more useful when we started the server on a Linux box remotely and ssh into that box and start the mojito app again and get this error and didn't know what was going on.

events.js:71
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: listen EADDRINUSE
    at errnoException (net.js:770:11)
    at HTTPServer.Server._listen2 (net.js:910:14)
    at listen (net.js:937:10)
    at HTTPServer.Server.listen (net.js:986:5)
    at MojitoServer.listen (/usr/local/lib/node_modules/mojito/lib/mojito.js:502:17)
    at Object.exports.run (/usr/local/lib/node_modules/mojito/lib/app/commands/start.js:89:9)
    at Function.CLI.run (/usr/local/lib/node_modules/mojito/lib/management/cli.js:176:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/mojito/bin/mojito:12:5)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
@rwaldura
Contributor

Good idea, but frankly Error: listen EADDRINUSE already says it all.

@jianlin
Contributor
jianlin commented Jan 16, 2013

I see some application programmers asking the same questions else where what is about EADDRINUSE... but as of other things in life, maybe it is not about how clear things are. It is about how unclear things are, and then there can be power over the other people. Just like lawyers will publish some forms that they know have some loopholes. So if the landlord use that form, he will run into issues and not know how to handle. It is not until the landlord pays $160 / hour, then the landlord can get the "professional service".

@rwaldura
Contributor

Agreed. Let's have a better error message, e.g.
"Port already in use. Is another Mojito, or another program, already running on this port?"
What do you think? I wish I could tell users how to get rid of this error, but doing so is very OS-specific.

@caridy
Collaborator
caridy commented May 17, 2013

@isao can we solve this at the cli level? In production, in 0.6.x we don't want to have a fancy error, only when running thru mojito start, in which case I think this belongs to the cli.

@isao
Contributor
isao commented May 21, 2013

@caridy yes, this should be handled by mojito-cli(-start). I'll migrate this issue once the org-repo is created

@isao isao referenced this issue in yahoo/mojito-cli-start Jun 4, 2013
@isao isao refactor
- fix requires/paths
- use mojito-cli api, env calcs, exports

new:
- check is-an-app
- check app depends on mojito
- check mojito is installed or specified
  - can specify --lib path/to/mojito
- do proper post-listen error handling
  - check EADDRINUSE
  - note these need yahoo/mojito#1150 to land, noop otherwise
- invoke cb when done
56b2dbc
@isao isao referenced this issue in yahoo/mojito-cli-start Jun 4, 2013
Closed

don't throw on EADDRINUSE, display friendlier error #5

@isao
Contributor
isao commented Jun 4, 2013

Hi @jianlin, @caridy, I put in a fix for this in mojito yahoo/mojito#1150

mojito-cli's start command takes advantage of that patch and this one to make a nicer "Port %d already in use." error.

Changes reflected in mojito@0.6.1 (just released) and mojito-cli@0.0.4 (latter to be published very soon)

@isao isao closed this Jun 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment