Primary server instance for a skyring app.
new (require("skyring/lib/server"))( [options])
Extends:
- http.Server
Parameters:
Name | Type | Argument | Default | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
|||||||||
optiopns.node.host |
String |
<optional> |
host name for the node to listen on - 127.0.0.1 must be used for localhost ( not 0.0.0.0 ) |
|||||||||
options.node.port |
Number |
<optional> |
Port number for the node to listen on in the ring |
|||||||||
options.node.app |
String |
<optional> |
timers | name of the active ring to join |
||||||||
options.nats |
Object |
<optional> |
Properties
|
|||||||||
options.transports |
Array.<String> | Array.<function()> |
<optional> |
an array of custom transport functions, or requireable paths that resolve to functions. All transport function must be named functions |
- Since:
-
- 1.0.0
- Source:
Examples
// Use only configuration values var server = new Server().listen(5000)
var server = new Server({ node :{ host: 172.17.0.9 , port: 8456 , app: 'payback' } , nats: { servers: ['nats1.domain.com:4222', 'nats2.domain.com:4222'] } }) server.listen(5000)
// Use a custom node instance var node = new Node({ host: 172.17.0.9 , port: 8456 , app: 'payback' }) var server = new Server({ node }) server.listen(5000)
Requires
- module:http
- module:debug
- module:@esaterwhite/micromock
- module:skyring/lib/server/node
- module:skyring/lib/server/router
- module:skyring/lib/timer
Methods
-
close(callback)
-
Removes a server from the ring, closes the http server and redistributes any pending timers
Parameters:
Name Type Description callback
function A callback to be called when the server is completely shut down
- Source:
-
listen(port [, host] [, backlog] [, callback])
-
Joins the node to the configured ring and starts the http server
Parameters:
Name Type Argument Default Description port
Number Port number to listen on
host
String <optional>
localhost host or ip address to listen on
backlog
Number <optional>
callback
function <optional>
Callback function to call when the server is running
- Source:
Returns: