Skip to content

Commit 29f38b9

Browse files
committed
feat: README, package and auto publishing
1 parent 54d5af6 commit 29f38b9

3 files changed

Lines changed: 156 additions & 14 deletions

File tree

.github/workflows/publish.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
id-token: write # Required for OIDC
10+
contents: read
11+
12+
jobs:
13+
publish:
14+
name: Publish to npm
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Bun
22+
uses: oven-sh/setup-bun@v2
23+
24+
- name: Use Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '22'
28+
registry-url: 'https://registry.npmjs.org'
29+
30+
- name: Install dependencies
31+
run: bun install --frozen-lockfile
32+
33+
- name: Build project
34+
run: bun run build
35+
36+
- name: Publish to npm
37+
run: npm publish

README.md

Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,105 @@
1-
# spm
1+
# SPM — Simpler Process Manager
22

3-
To install dependencies:
3+
A minimal process manager implementing a lean subset of [pm2](https://pm2.keymetrics.io/) features, with some extensions, designed for better development script setup. Lightweight, zero daemon, and ecosystem config compatible.
4+
5+
## Features
6+
7+
- **Start / Stop / Restart** — Manage multiple services from a single config
8+
- **Multi-instance** — Run multiple instances with port/env auto-increment
9+
- **Log management** — Tail, filter, flush, and rotate logs
10+
- **JSON output**`jlist` for machine-readable status (CI/scripting)
11+
- **Log rotation** — Size-based rotation and retention with optional background watcher
12+
13+
## Installation
14+
15+
```bash
16+
npm install -g @hackmd/spm
17+
```
18+
19+
Or with Bun:
20+
21+
```bash
22+
bun add -g @hackmd/spm
23+
```
24+
25+
## Quick Start
26+
27+
1. Create an ecosystem config file (e.g. `ecosystem.config.js`) in your project:
28+
29+
```javascript
30+
export default {
31+
apps: [
32+
{
33+
name: 'api',
34+
script: 'node',
35+
args: 'server.js',
36+
instances: 2,
37+
env: { PORT: '3000' },
38+
increment_vars: ['PORT'],
39+
},
40+
{
41+
name: 'worker',
42+
script: 'node',
43+
args: 'worker.js',
44+
},
45+
],
46+
}
47+
```
48+
49+
2. Run SPM:
450

551
```bash
6-
bun install
7-
bun run build
52+
spm start # Start all services
53+
spm start api # Start specific service
54+
spm list # List services and PIDs
55+
spm stop # Stop all
56+
spm restart api # Restart specific service
57+
spm logs api -t # Tail logs
858
```
959

10-
Install locally global
60+
## Configuration
61+
62+
| Option | Description |
63+
|--------|-------------|
64+
| `name` | Service identifier |
65+
| `script` | Command to run (e.g. `node`, `bun`, `python`) |
66+
| `args` | Arguments passed to the script |
67+
| `instances` | Number of instances (default: 1) |
68+
| `env` | Environment variables |
69+
| `increment_vars` | Env vars to increment per instance (e.g. `PORT`) |
70+
71+
Config file is resolved from `./ecosystem.custom.config.js` by default. Override with `--config`:
1172

1273
```bash
13-
npm i . -g
74+
spm --config ./my-ecosystem.config.js start
1475
```
1576

16-
## Shell completions
77+
## Commands
78+
79+
| Command | Description |
80+
|---------|-------------|
81+
| `spm start [service]` | Start all or a specific service |
82+
| `spm stop [service]` | Stop processes (alias: `kill`) |
83+
| `spm restart [service]` | Restart processes |
84+
| `spm list` | List services and running PIDs |
85+
| `spm jlist` | JSON output of service status |
86+
| `spm logs [service]` | View logs (`-t` tail, `-n` lines, `-f` filter) |
87+
| `spm flush [service]` | Clear log files |
88+
| `spm rotate start` | Start log rotation watcher |
89+
| `spm rotate stop` | Stop rotation watcher |
90+
91+
## Log Rotation
92+
93+
Logs are stored in `~/.spm2/logs/`. Rotation:
94+
95+
- Rotates when a log exceeds 10MB
96+
- Removes logs older than 3 days
97+
- Run `spm rotate start` for a background watcher
98+
99+
## Shell Completions
100+
101+
See [Yukaii/dotfiles](https://github.com/Yukaii/dotfiles/commit/569b50824c19340cefb308f385168492418f98e7) for shell completion setup.
102+
103+
## License
17104

18-
Take a look at https://github.com/Yukaii/dotfiles/commit/569b50824c19340cefb308f385168492418f98e7
105+
MIT

package.json

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
11
{
2-
"name": "spm",
2+
"name": "@hackmd/spm",
3+
"version": "0.1.0",
4+
"description": "Simpler Process Manager - minimal pm2-like features for better development script setup",
35
"module": "index.ts",
46
"type": "module",
57
"scripts": {
68
"build": "bun build index.ts --target node --outdir dist",
7-
"postinstall": "npm run build"
9+
"postinstall": "bun run build"
810
},
911
"bin": {
1012
"spm": "./dist/index.js"
1113
},
12-
"devDependencies": {
13-
"@types/bun": "latest"
14+
"files": [
15+
"dist"
16+
],
17+
"repository": {
18+
"type": "git",
19+
"url": "https://github.com/hackmdio/spm.git"
1420
},
15-
"peerDependencies": {
16-
"typescript": "^5.0.0"
21+
"bugs": "https://github.com/hackmdio/spm/issues",
22+
"homepage": "https://github.com/hackmdio/spm#readme",
23+
"keywords": [
24+
"process-manager",
25+
"pm2",
26+
"development",
27+
"cli"
28+
],
29+
"license": "MIT",
30+
"publishConfig": {
31+
"access": "public"
1732
},
1833
"dependencies": {
1934
"commander": "^13.1.0"
35+
},
36+
"devDependencies": {
37+
"@types/bun": "latest"
2038
}
2139
}

0 commit comments

Comments
 (0)