The Server Application

The asimov.js framework itself doesn’t serve HTTP. That job belongs to the asimov-server plugin, which is mounted like any other plugin in your index.js.

index.js
var asimov = require('asimov');
var server = require('asimov-server');
var pages = require('asimov-pages');
module.exports = function plugin () {
asimov.use(server);
asimov.use(pages);
};
module.exports.start = function bootstrap () {
asimov.use(module.exports).start();
};
module.parent || module.exports.start();

Master and workers

Internally, the framework is split into two roles: a Master process that supervises, and one or more Worker processes that actually handle requests. This is controlled by process.env.ROLE, which defaults to master. Workers are forked with ROLE=worker.

// asimov/index.js (excerpt)
process.env.ROLE = process.env.ROLE || 'master';
var isMaster = process.env.ROLE === 'master';
var Asimov = isMaster ? require('./lib/Master') : require('./lib/Worker');

The master listens for IPC messages from workers:

This is what powers rolling restarts (see Initializers) without dropping in-flight requests.

Middleware

Once asimov-server is mounted, it exposes asimov.use()-style hooks that accept any Express-compatible middleware. See Middleware for the full surface area.

Lifecycle state

While the app is running, asimov.config('state') reflects the lifecycle — one of starting, running, or stopping. Plugins can read this to decide whether to accept new work, drain in-flight tasks, or skip themselves entirely.