Skip to content

Implementation and start

Efra Espada edited this page Mar 31, 2018 · 3 revisions

Install the package:

npm install rotor-server --save

Implement on the main process of your API:

const RotorServer = require('rotor-server');

Start server

Rotor server wakes up few process. The first one is the sentinel process, which preloads JSON databases. The rest are clusters (except master of course) which process all device requests updating databases (with sentinel process) and replicating changes (with Redis).

Don't worry about start or stop them. They will alive with your API process. Start it by calling start() method:

const RS = new RotorServer();
RS.start({
    ready: function () {
        ...
    },
    config: {
        "server_port": 1507,
        "redis_port": 6379,
        "db_name": "myDatabase",
        "debug": true
    }
});