# pm2sd

> Node.js Process Manager over systemd service

Latest version **0.0.48** (published 2023-01-08) · MIT license · 0 weekly downloads

## Install

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

Provides the command `pm2sd`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.48 |
| Published | 2023-01-08 |
| First published | 2022-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 514.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Artem Dudkin |
| Maintainers | artemdudkin |

## Links

- npm: https://www.npmjs.com/package/pm2sd
- Repository: https://github.com/artemdudkin/pm2sd
- Homepage: https://github.com/artemdudkin/pm2sd#readme
- Issues: https://github.com/artemdudkin/pm2sd/issues
- npm.io page: https://npm.io/package/pm2sd

## Dependencies (1)

- [cli-color](https://npm.io/package/cli-color.md) ^2.0.3

## Recent versions

- 0.0.48 (latest) — 2023-01-08
- 0.0.47 — 2023-01-05
- 0.0.46 — 2023-01-05
- 0.0.45 — 2023-01-05
- 0.0.44 — 2023-01-05
- 0.0.43 — 2023-01-05
- 0.0.42 — 2023-01-01
- 0.0.41 — 2023-01-01
- 0.0.40 — 2022-12-31
- 0.0.39 — 2022-12-17
- 0.0.38 — 2022-12-17
- 0.0.37 — 2022-12-17
- 0.0.36 — 2022-12-17
- 0.0.35 — 2022-12-08
- 0.0.34 — 2022-12-08
- … 32 more at https://npm.io/package/pm2sd/versions

## README

# pm2sd
PM2SD is a process manager for Node.js applications (or other scripts) built over system services. It is inspired by PM2, but not that complex and uses far less memory (i.e. zero memory as it is wrapper for systemd service at Linux, for instance). I love PM2, but cannot use it on small VPS for pet projects, so meet the PM2SD!

You can start process as simple as

```bash
$ pm2sd start index.js
```

Process will be started as system service (i.e. added to /etc/systemd/system at Linux), enabled for restart after reboot, will restart in 30 seconds if it crashes, output and error logs goes to `/var/log/pm2sd-<name>` (if you want configure and start service under non-privileged user, you need to do some [magic](./doc/d-bus-black-magic.md)). 

**No clusters, no load balancers, no watching, just one living process.**

It works on Linux, and Windows is in the plans :construction: :hammer:.

## Commands

Implemented commands: ls, start, stop, restart, delete, log.

### ls

Lists all pm2sd services. Also, you can get list of all system services with option `--all`:

```bash
$ pm2sd ls --all
```
<img width=600px src="https://raw.githubusercontent.com/artemdudkin/pm2sd/main/doc/ls.png" alt="ls output">

You can filter list of all services by part of its name with `pm2sd ls <name>`.

Also you can use `--json` option to get json instead of colored text output.

### start

Starts new process. Avaliable options: name, description, time, user (i.e. service can be started from any user). 
`--time` adds timestamp to logs.

```bash
$ pm2sd start index.js --name=test --user=node --time
```

### stop

Stops process (by its name).

### restart

Restarts process (by its name).

### delete

Delete all traces of process (include logs).

### log

Tails log of selected process (`pm2sd log <name>`) or logs for all processes if nothing specified (`pm2sd log`).

## Troubleshooting

1. If you've got `Failed to connect to D-Bus` that means you're trying to work under non-root user, which requires the systemd user service to be started (look at [this](./doc/d-bus-black-magic.md)).

2. If service does not start at boot for non-root user, please check if user lingering is enabled (look at [this](./doc/d-bus-black-magic.md)).

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