-
Download the installation script:
wget https://raw.githubusercontent.com/SiliconSquire/pypm/main/install_pypm.sh -
Make the script executable:
chmod +x install_pypm.sh -
Run the installation script as root:
sudo ./install_pypm.sh -
When prompted, enter the username for which you want to install PyPM.
-
The script will install all necessary dependencies, set up PyPM for the specified user, and enable PyPM to start automatically on system boot.
After installation, the specified user can use PyPM with the following commands:
-
Start a new process:
pypm start <process_name> "<command>"Example:
pypm start myapp "python3 app.py"(py script must be in the same folder as the venv)Note: PyPM now validates that the Python script exists before starting the process.
-
List all managed processes:
pypm listThe list command now shows more detailed information including CPU usage, memory usage, and restart count.
-
Stop a process:
pypm stop <process_name> -
Restart a process:
pypm restart <process_name> -
Delete a process from PyPM management:
pypm delete <process_name> -
Save current processes for autostart:
pypm save -
Set up autostart for managed processes on system boot:
pypm startup -
Disable autostart for managed processes:
pypm disable-startup -
Stop PyPM itself:
pypm stop-self -
Restart PyPM:
pypm restart-self -
Enable PyPM autostart (already done during installation):
pypm enable -
Disable PyPM autostart:
pypm disable -
Configure process settings:
pypm config <process_name> <key> <value>Example:
pypm config myapp max_restarts 10Available settings:
max_restarts: Maximum number of restart attempts (default: 5)restart_delay: Initial delay in seconds between restarts (default: 3)
-
Check PyPM status:
pypm statusShows information about PyPM including PID, log file location, and autostart status.
You can manage multiple processes easily. Here's an example workflow:
cd /path/to/app1
pypm start app1 "python3 app1.py"
cd /path/to/app2
pypm start app2 "python3 app2.py"
pypm list # View all running processes
pypm save # Save current processes for autostart
pypm startup # Set up autostart for managed processes on system boot- Virtual Environment Support: PyPM automatically detects and uses virtual environments if they exist in your project directory.
- Background Execution: Processes started with PyPM run in the background, allowing you to continue using your terminal.
- Autostart Capability: The
pypm saveandpypm startupcommands ensure your managed processes start automatically after system reboot. - Process Monitoring: PyPM monitors processes and automatically restarts them if they crash, with exponential backoff.
- Resource Usage Tracking: The
pypm listcommand shows CPU and memory usage for each process. - Logging: PyPM now logs all actions to
~/.pypm.logfor better troubleshooting. - Graceful Shutdown: PyPM handles signals properly to ensure clean shutdown of managed processes.
- Process Validation: PyPM validates process names and commands before execution to prevent errors.
- Configurable Settings: Process settings like restart limits can be configured with the
pypm configcommand.
If you're transitioning from systemd to PyPM, you can remove old systemd services with these commands (run as root):
systemctl stop service1.service service2.service service3.service
systemctl disable service1.service service2.service service3.service
rm /etc/systemd/system/{service1.service,service2.service,service3.service}
systemctl daemon-reloadReplace service1, service2, etc., with your actual service names.
If you encounter any issues:
- Check the log file at
~/.pypm.logfor detailed error messages. - Ensure the user has the necessary permissions to run the processes.
- Check the project directory for a virtual environment if your Python app requires specific dependencies.
- Verify that all required Python packages are installed in the project's virtual environment.
- If PyPM isn't starting automatically on boot, check its status with
pypm statusand re-enable if necessary. - For issues with managed processes not starting, check the autostart configuration with
pypm startup. - Make sure your Python scripts exist in the specified directory before starting them.
For any persistent problems or feature requests, please open an issue on the GitHub repository.