RingoJS

Module ringo/httpserver/index

A module containing build and daemon lifecycle methods for http server

Functions

Properties


HttpServer

A named export of the HttpServer module.


build (options)

Returns a new HttpServerBuilder instance

Parameters

String|Object options

Either the path to the jetty.xml configuration file, or an object containing the following properties:

  • stopAtShutdown: (boolean, default: true)
  • stopTimeout: (Number, default: 1000 millis)
  • dumpBeforeStart: (boolean, default: false)
  • dumpBeforeStop: (boolean, default: false)

Returns

HttpServerBuilder

A newly created HttpServerBuilder instance


destroy ()

Daemon life cycle function invoked by init script. Frees any resources occupied by the Server instance. If the application exports a function called destroy, it will be invoked with the server as argument.

Returns

Server

the Server instance.


init (path)

Daemon life cycle function invoked by init script. Creates a new Server with the application at appPath. If the application exports a function called init, it will be invoked with the new server as argument.

Parameters

String path

Optional application file name or module id. If undefined, the first command line argument will be used as application. If there are no command line arguments, module main in the current working directory is used.

Returns

Server

the Server instance.


main (path)

Main function to start an HTTP server from the command line. It automatically adds a shutdown hook which will stop and destroy the server at the JVM termination.

Example

// starts the current module via module.id as web application
require("ringo/httpserver").main(module.id);

// starts the module "./app/actions" as web application
require("ringo/httpserver").main(module.resolve('./app/actions'));

Parameters

String path

optional application file name or module id.

Returns

Server

the Server instance.


start ()

Daemon life cycle function invoked by init script. Starts the Server created by init(). If the application exports a function called start, it will be invoked with the server as argument immediately after it has started.

Returns

Server

the Server instance.


stop ()

Daemon life cycle function invoked by init script. Stops the Server started by start().

Returns

Server

the Server instance. If the application exports a function called stop, it will be invoked with the server as argument immediately before it is stopped.