# satan-pm

> Satan Process Manager

Latest version **2.0.3** (published 2016-06-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install satan-pm
pnpm add satan-pm
yarn add satan-pm
bun add satan-pm
```

Provides the command `satan`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2016-06-27 |
| First published | 2015-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+7 in 2 direct dependencies) |
| Install scripts | no |
| Author | Jonathan Lima |
| Maintainers | greenboxal |
| Keywords | process, manager |

## Links

- npm: https://www.npmjs.com/package/satan-pm
- Repository: https://github.com/pagarme/satan-pm
- Issues: https://github.com/pagarme/satan-pm/issues
- npm.io page: https://npm.io/package/satan-pm

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^3.3.1
- [log4js](https://npm.io/package/log4js.md) ^0.6.22
- [bluebird](https://npm.io/package/bluebird.md) ^2.9.34
- [commander](https://npm.io/package/commander.md) ^2.6.0

## Recent versions

- 2.0.3 (latest) — 2016-06-27
- 2.0.2 — 2015-09-07
- 2.0.1 — 2015-09-07
- 2.0.0 — 2015-09-07
- 1.2.4 — 2015-04-20
- 1.2.3 — 2015-04-19
- 1.2.2 — 2015-04-18
- 1.2.1 — 2015-04-13
- 1.1.3 — 2015-04-09
- 1.1.2 — 2015-04-09
- 1.1.1 — 2015-04-09
- 1.1.0 — 2015-04-09
- 1.0.1 — 2015-04-08

## README

# satan-pm
[![Build Status](https://travis-ci.org/pagarme/satan-pm.svg)](https://travis-ci.org/pagarme/satan-pm) [![Coverage Status](https://coveralls.io/repos/pagarme/satan-pm/badge.svg?branch=master)](https://coveralls.io/r/pagarme/satan-pm?branch=master)

Upstart friendly node.js cluster manager.

# Usage

```
  Usage: satan [options] -- [args...]

  Options:

    -h, --help                      output usage information
    -V, --version                   output the version number
    -s, --script [path]             worker script path
    -d, --working-directory [path]  working directory
    -i, --instances [count]         number of workers to spawn
    -n, --node-arguments [args]     custom arguments to nodejs
    -p, --scheduling-policy         cluster scheduling policy(none or rr)
    -c, --config [path]             config file path
    -p, --pid-file [path]           pid file path
```

# Graceful Reload

When satan-pm process receives a `SIGHUP` signal, it will gracefully reload all workers, each at a time.

To do so, it will trigger a disconnect on the worker with `cluster.worker.disconnect()`.

You can hook up the shutdown process to do a custom cleanup procedure(e.g.: you have a worker consuming a Redis queue). For this you need to add a listener to the `shutdown` event on the `process` global.

Please note that when you listen to the `shutdown` event you are responsible for terminating the process(i.e.: calling `cluster.worker.disconnect()`).

# Graceful Shutdown

`satan-pm` will also do a graceful shutdown when it receives a `SIGTERM` or `SIGINT` signal. The behaviour is exactly the same as the graceful reload.

# Example

## config.json
```
{
	"workingDirectory": "/app/your-server/current",
	"script": "bin/server.js",
	"arguments": "-p 3000",
	"instances": 4
}
```

Running:

```sh
satan -c config.json
```

# Bonus: GC Signal

When `satan-pm` receives a `SIGUSR2` it will trigger a garbage collection. This is useful when debugging memory leaks or when you need to clean up the memory before a reload.

# Bonus: Upstart Configuration

This is a example upstart configuration that plays well with satan:

```upstart
start on started networking
stop on stopping networking

respawn
respawn limit 5 20

reload signal SIGHUP

chdir /app/your-server/current

setuid deploy
setgid deploy

env NODE_ENV=production

exec /usr/bin/satan -c /app/your-server/shared/satan.json

```

# License

Check [here](LICENSE).

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