webd
- HTTP super-server
Sort of like inetd but for web services only.
Spins services up on demand and then proxies to them, shutting them down after they don't get any requests for a while.
Features:
- Zero dependencies outside of Node standard library
Host
-based routing- Automatic startup and shutdown of backends
Bugs (patches gladly accepted!):
- Primitive error handling (dump a stack trace into the HTTP response)
- No support for HTTPS, on either end
- Probably doesn't handle things like websockets
- No logging support
- No test suite
Usage
Synopsis
./webd.js ./config.example.json
Configuration
webd.js
expects one argument, a config.js
or config.json
file (see config.example.json
).
Config options:
listen
(required, object): Options forserver.listen()
.indexHost
(optional, string): If specified, aHost
name which will be served a simple HTML page with links to all available backends.backends
(required, object): Map ofHost
name to backend configurations with the following keys:connectionOptions
(required, object): Options forhttp.request()
.host
defaults to "localhost" unless overridden.run
(optional, object): Options for starting the backend.cwd
(optional, string): directory tocd
to before starting the commandcommand
(required, string): command to runargs
(required, string[]): arguments to pass to command (note that they must be split already unless you're usingshell
)shell
(optional, boolean): Iftrue
,command
is passed to a shell; seechild_process.spawn()
for details.
shutdownAfter
(optional, number, milliseconds): How long to wait for another request before shutting down the backend. (If not specified, the backend will be started on the first request and will never be shut down.)