Skip to main content

Like pm2 without node.js ;-)

Project description

PM3

Like pm2 without node.js ;-)

PM3 CheatSheet:

Install and update

Build a virtualenv environment (recommended)

python3.9 -m venv PM3venv
. PM3venv/bin/activate

Then:

pip install pm3             # Install pm3
pip install -U pm3          # Upgrade pm3

Start

pm3 daemon start    # Start process with default ~/.pm3/config.ini configuration 
pm3 ping            # Ensure pm3 daemon has been launched

Create new process

pm3 new '/bin/sleep 10' -n sleep10                                  # Create a new process with name sleep10
pm3 new '/bin/sleep 10' -n sleep10 --autorun                        # Create a new process with autorun option
pm3 new "script.py" --interpreter "/venv/bin/python" --cwd "/tmp"   # Create a new process with interpreter and cwd definition
pm3 new '/bin/sleep 5' --max-restart 10 --autorun                   # Stops restarting the process after 10 restarts        

Actions

pm3 start sleep10   # Start process with name sleep10
pm3 start 1         # Start process with id 1
pm3 restart all     # Restart all process
pm3 stop 2          # Stop process with id 2 
pm3 rm 3            # Stop and delete process with id 3

Listing

pm3 ls                 # Display all processes
pm3 ls -l              # Display all processes in list format
pm3 ls -j              # Display all processes in json format
pm3 ps 5               # Display process 5 status
pm3 ps -l ALL          # Display ALL processes (hidden or not) status in list format
pm3 ps -j ALL          # Display ALL processes (hidden or not) status in json format

Dump and Load

pm3 dump 2                  # Print process 2 configuration in JSON
pm3 dump all -f dump.json   # Save all configuration processes in dump.json file 
pm3 load dump.json          # Load all configuration processes from dump.json file 

Logs

pm3 log            # Display all processes logs
pm3 log 5 -f       # Display and follow log of process 5
pm3 err 2 -n 50    # Display last 50 rows of process 5 error log 
pm3 flush 1 log    # Empty log file of process 1
pm3 flush all err  # Empty err file of all process

Useful script generation

pm3 make_script systemd     # Generate script for install startup systemd configuration
pm3 make_script pm3_edit    # Generate script for edit process configuration on the fly 

Misc

pm3 reset 2                 # Reset meta data of process id 2
pm3 ping [-v]               # Ensure pm3 daemon has been launched [verbose]
pm3 rename 3 -n <new_name>  # Rename process id 3 with a <new_name>
pm3 -h                      # General help
pm3 new -h                  # Help of new subcommand  

Daemon commands

pm3 daemon start        # Start PM3 backend porcess
pm3 daemon stop         # Stop PM3 backend porcess
pm3 daemon status       # Check daemon status details

Configuration file:

$ cat ~/.pm3/config.ini

[main_section]
pm3_home_dir = /home/user/.pm3                  # pm3 home dir
pm3_db = /home/user/.pm3/pm3_db.json            # TinyDB Store File
pm3_db_process_table = pm3_procs                # TinyDB process table
main_interpreter = /home/user/venv/bin/python   # path of python interpreter

[backend]
name = __backend__                       # name of backend process (hidden process)
url = http://127.0.0.1:7979/             # proto://ip:port of backend (if != 127.1 is a potential RISK!!)
cmd = /home/user/venv/bin/pm3_backend    # path of backend command

[cron_checker]
name = __cron_checker__                      # name of backend process (hidden process)
cmd = /home/user/venv/bin/pm3_cron_checker   # path of cron checker command
sleep_time = 5                               # Time (in seconds) to check process                            
debug = False                                # Crocn Checker debug info

Autocompletition (experimental)

Bash

pm3_exe=$(which pm3)
eval "$(register-python-argcomplete $pm3_exe)"

Fish

pm3_exe=$(which pm3)
register-python-argcomplete --shell fish $pm3_exe | source

or

register-python-argcomplete --shell fish $pm3_exe > ~/.config/fish/completions/pm3.fish

Other shell

visit https://kislyuk.github.io/argcomplete/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PM3-0.3.20.tar.gz (447.3 kB view details)

Uploaded Source

Built Distribution

PM3-0.3.20-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file PM3-0.3.20.tar.gz.

File metadata

  • Download URL: PM3-0.3.20.tar.gz
  • Upload date:
  • Size: 447.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.16

File hashes

Hashes for PM3-0.3.20.tar.gz
Algorithm Hash digest
SHA256 d4eaa7921a5d150b8b2c9fcd89824c552db664f3342a8c2c6043b01f755194f2
MD5 84a31b769838a9d6ee941c7e4fe8ff72
BLAKE2b-256 f8165d964236b60c4320d12239050cf9b46efb4d1e7c11432d7e27e39a8745e7

See more details on using hashes here.

File details

Details for the file PM3-0.3.20-py3-none-any.whl.

File metadata

  • Download URL: PM3-0.3.20-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.16

File hashes

Hashes for PM3-0.3.20-py3-none-any.whl
Algorithm Hash digest
SHA256 d1cb2ad151ad120f6c55b1b2e2609498bb60d142f60061ec8cd3d88a2d4b7388
MD5 e2e422fef4c530796484e23c4344ba81
BLAKE2b-256 7d31a826f73726e040cd9dcc096b363a47e2466a2873465a92f1e2d893346811

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page