
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
This Python library provides a seamless integration with PM2, enabling users to automate the launching and management of processes using PM2 through Python. Designed to cater to developers and system administrators who require a programmable interface to control their processes with the power and flexibility of Python, this library simplifies interactions with PM2, making it more accessible and versatile.
To install the PM2 Python Library, run the following command:
pip install pm2
To get started with the PM2 Python Library, here's a simple example that demonstrates how to start a process:
from pm2 import PM2, AioPM2
import asyncio
pm2 = PM2()
aiopm2 = AioPM2()
# Sync Methods
def pm2_manager():
# List all processes
processes = pm2.list()
print(processes)
# Start a process
pm2.start(
"your_script.py",
name="Script-Name",
extra_args=["-arg1", "value1"],
name="YourProcessName",
)
# Restart a process
pm2.restart(name="Script-Name") # or pid=12345 or pm_id=1
# Stop a process
pm2.stop(name="Script-Name") # or pid=12345 or pm_id=1
# Delete a process
pm2.delete(name="Script-Name") # or pid=12345 or pm_id=1
# Async Methods
async def pm2_manager():
# List all processes
processes = await aiopm2.list()
print(processes)
# Start a process
await aiopm2.start(
"your_script.py",
name="Script-Name",
extra_args=["-arg1", "value1"],
name="Script-Name",
)
# Restart a process
await aiopm2.restart(name="Script-Name") # or pid=12345 or pm_id=1
# Stop a process
await aiopm2.stop(name="Script-Name") # or pid=12345 or pm_id=1
# Delete a process
await aiopm2.delete(name="Script-Name") # or pid=12345 or pm_id=1
# Run the function
pm2_manager()
# or
asyncio.run(pm2_manager())
Replace 'your_script.py'
, 'Script-Name'
, and the args as necessary to fit your needs.
Contributions are welcome! If you would like to contribute, please follow these steps:
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Python wrapper for PM2
We found that pm2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.