mjackson / strata

A modular, streaming HTTP server for node.js

Home Page:http://stratajs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Show how to listen on a particular port

marktorrance opened this issue · comments

I'm still stuck trying to figure out how to make strata listen on a port of my choice other than the default port. An example of this, in the README or in the manual somewhere in the early chapters would be really useful.

The closest thing I found was a comment in the SPEC saying that the server port can be overridden in the environment, but I have tried this:

process.env.SERVER_PORT = 2100;

and this:

% setenv SERVER_PORT 2100
% node app.js

and neither has worked.

I'm sure I'll figure it out soon by poking around, but this is a really common need.

Found my answer in the source code -- index.js, source of the run() function, says I can provide {port:2100} as an optional 2nd parameter to run(). That's not yet shown in the manual.

Thanks for the feedback. Going to add an example showing the use of strata.run with a second argument in the manual.

As far as process.env.SERVER_PORT goes, the intent was to provide users a way to override the value of the serverPort environment variable, not the actual port that node binds too. I agree that this can be confusing, and I'm not yet 100% sure that's how it should behave, but that is its current behavior.

I added an example to the manual in this commit.