PM (process manager)
Installation
PM is available only for linux due to heavy usage of linux mechanisms. Go to the releases page to download the latest binary.
# download binary
wget https://github.com/rprtr258/pm/releases/latest/download/pm_linux_amd64
# make binary executable
chmod +x pm_linux_amd64
# move binary to $PATH, here just local
mv pm_linux_amd64 pm
Systemd service
To enable running processes on system startup:
# soft link /usr/bin/pm binary to whenever it is installed
sudo ln -s ~/go/bin/pm /usr/bin/pm
# install systemd service, copy/paste output of following command
pm startup
After these commands, processes with startup: true
config option will be started on system startup.
Configuration
jsonnet configuration language is used. It is also fully compatible with plain JSON, so you can write JSON instead.
See example configuration file. Other examples can be found in tests directory.
Usage
Most fresh usage descriptions can be seen using pm <command> --help
.
Run process
# run process using command
pm run go run main.go
# run processes from config file
pm run --config config.jsonnet
List processes
pm list
Start already added processes
pm start [ID/NAME/TAG]...
Stop processes
pm stop [ID/NAME/TAG]...
# e.g. stop all added processes (all processes has tag `all` by default)
pm stop all
Delete processes
When deleting process, they are first stopped, then removed from pm
.
pm delete [ID/NAME/TAG]...
# e.g. delete all processes
pm delete all
Process state diagram
Development
Architecture
pm
consists of two parts:
- cli client - requests server, launches/stops shim processes
- shim - monitors and restarts processes, handle watches, signals and shutdowns
PM directory structure
pm
uses directory $HOME/.pm
to store data by default. PM_HOME
environment variable can be used to change this. Layout is following:
$HOME/.pm/
├──config.json # pm config file
├──db/ # database tables
│ └──<ID> # process info
└──logs/ # processes logs
├──<ID>.stdout # stdout of process with id ID
└──<ID>.stderr # stderr of process with id ID
Differences from pm2
pm
is just a single binary, not dependent onnodejs
and bunch ofjs
scripts- jsonnet configuration language, back compatible with
JSON
and allows to thoroughly configure processes, e.g. separate environments without requiring corresponding mechanism inpm
(others configuration languages might be added in future such asProcfile
,HCL
, etc.) - supports only
linux
now - I can fix problems/add features as I need, independent of whether they work or not in
pm2
because I don't knowjs
- fast and convenient (I hope so)
- no specific integrations for
js
Release
On master
branch:
git tag v1.2.3
git push --tags
goreleaser release --clean