# clustero

> **Example**

Latest version **0.0.1** (published 2018-04-03) · 0 weekly downloads

## Install

```sh
npm install clustero
pnpm add clustero
yarn add clustero
bun add clustero
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2018-04-03 |
| First published | 2018-04-03 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 46.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | innometrics |

## Links

- npm: https://www.npmjs.com/package/clustero
- npm.io page: https://npm.io/package/clustero

## Recent versions

- 0.0.1 (latest) — 2018-04-03

## README

# clustero

**Example**

Your app's files:
* package.json
```
...
"scripts": {
    "start": "node server.js",
    "start-cluster": "node server-cluster.js",
}
...
```
* server-cluster.js
```javascript
const cluster = require('clustero');
cluster.setupMaster({
    exec: 'server.js'
});
```
* server.js

```javascript
const clustero = require('clustero');

function initApp () {
    const app = new MyApp();
    return app;
}

function doWriteErrorLog (error) {
    console.error(error);
    const timer = setTimeout(() => {
        clearInterval(timer);
        process.exit(1);
    }, 100);
}

module.exports = clustero.initApp((worker, gracefulKiller) => {
    process.on('error', doWriteErrorLog);
    process.on('uncaughtException', doWriteErrorLog);

    const app = initApp();
    server.app('error', doWriteErrorLog);

    const stopApp = callback => app.shutdown(callback);
    const kill = () => gracefulKiller(stopApp);

    // on STOP service
    process.on('SIGTERM', kill);
    // on CTRL+C
    process.on('SIGINT', kill);
});

```

Run in single mode: **npm start**

Run in cluster mode: **npm run start-cluster**

---
_Source: https://npm.io/package/clustero · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
