Skip to content

prismatex/python-manager

Repository files navigation

Python Manager 🐍

License: MIT Python 3.7+ Flask

A web-based tool for managing multiple Python scripts with real-time monitoring, logging, and control. Perfect for managing microservices, data pipelines, background jobs, or any collection of Python scripts.

Python Manager Dashboard

✨ Features

  • πŸš€ Multi-Script Management: Start, stop, and restart Python scripts from anywhere on your system
  • πŸ“Š Real-time Monitoring: Track CPU and memory usage for each script
  • πŸ”„ Auto-Restart: Automatically restart scripts on failure with configurable retry limits
  • πŸ“ Centralized Logging: View logs for all scripts in one place
  • 🌐 Web Interface: Modern, responsive dashboard accessible from any browser
  • πŸ”Œ REST API: Full API for programmatic control and automation
  • πŸ“ Flexible Path Support: Add scripts from ANY location on your system
  • ⚑ WebSocket Support: Real-time status updates without page refresh
  • 🎯 Easy Deployment: Multiple installation options for different use cases

πŸš€ Quick Start

Option 1: Interactive Setup (Recommended)

git clone https://github.com/yourusername/python-manager.git
cd python-manager
python deploy/setup.py

Option 2: Direct Run

# Clone the repository
git clone https://github.com/yourusername/python-manager.git
cd python-manager

# Install requirements
pip install -r requirements.txt

# (Optional) Download Socket.IO for offline use
python download_socketio.py

# Start the manager
python start_manager.py

Then open your browser to: http://localhost:5000

πŸ“¦ Socket.IO Setup

Python Manager uses Socket.IO for real-time updates. By default, it loads from CDN (cdnjs.cloudflare.com). For offline use or better reliability:

python download_socketio.py

This downloads Socket.IO locally (MIT licensed, freely redistributable). The application automatically falls back to the local file if CDN is unavailable.

πŸ“‹ Requirements

  • Python 3.7 or higher
  • pip (Python package manager)

Required packages (automatically installed):

  • Flask
  • Flask-SocketIO
  • Flask-CORS
  • psutil

🎯 Usage

Adding Scripts

  1. Via Web Interface (Easy):

    • Click the "βš™ Manage Scripts" button
    • Enter the full path to your Python script or browse for it
    • Configure display name, arguments, and auto-restart options
    • Click "Add Script"
  2. Via Configuration File: Edit py_manager/config.json:

    {
      "scripts": [
        {
          "id": "my_script",
          "name": "My Awesome Script",
          "path": "C:/path/to/your/script.py",
          "args": ["--arg1", "value"],
          "auto_restart": true,
          "enabled": true,
          "max_memory_mb": 512,
          "log_file": "my_script.log"
        }
      ]
    }

Managing Scripts

  • Start/Stop: Click the respective buttons on each script card
  • View Logs: Click "View Logs" to see real-time output
  • Bulk Actions: Use "Start All" or "Stop All" for multiple scripts
  • Auto-restart: Enable to automatically restart failed scripts

πŸ› οΈ API Usage

Python Manager provides a REST API for automation:

import requests

# Base URL
base_url = "http://localhost:5000/api"

# Start a script
response = requests.post(f"{base_url}/scripts/my_script/start")

# Stop a script
response = requests.post(f"{base_url}/scripts/my_script/stop")

# Get all scripts status
response = requests.get(f"{base_url}/scripts/status")
print(response.json())

# Get logs
response = requests.get(f"{base_url}/scripts/my_script/logs?lines=50")

API Endpoints

Method Endpoint Description
GET /api/health Health check
GET /api/scripts List all scripts
GET /api/scripts/status Get status of all scripts
POST /api/scripts/{id}/start Start a script
POST /api/scripts/{id}/stop Stop a script
POST /api/scripts/{id}/restart Restart a script
GET /api/scripts/{id}/logs Get script logs
POST /api/scripts/add Add new script
DELETE /api/scripts/{id}/remove Remove script

πŸ“¦ Deployment Options

For Development Projects

python deploy/setup.py

Follow the interactive prompts to set up Python Manager in your project.

For Production

  1. Clone to your server
  2. Set up as a systemd service (Linux) or Windows Service
  3. Configure authentication in api_config.json
  4. Use a reverse proxy (nginx/Apache) for HTTPS

Create Portable Package

python deploy/create_package.py

This creates a distributable ZIP file with everything needed.

πŸ—οΈ Project Structure

python-manager/
β”œβ”€β”€ start_manager.py      # Main entry point
β”œβ”€β”€ allin1.py            # All-in-one server
β”œβ”€β”€ requirements.txt     # Python dependencies
β”œβ”€β”€ py_manager/          # Core modules
β”‚   β”œβ”€β”€ py_process.py    # Process management
β”‚   β”œβ”€β”€ py_logger.py     # Logging system
β”‚   β”œβ”€β”€ py_api.py        # REST API
β”‚   β”œβ”€β”€ py_manager.html  # Web interface
β”‚   └── ...
β”œβ”€β”€ scripts/             # Example scripts
β”œβ”€β”€ logs/               # Log files
└── deploy/             # Deployment tools

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with Flask and Flask-SocketIO
  • Process monitoring powered by psutil
  • UI inspired by modern dashboard designs

πŸ“§ Support

  • Create an Issue for bug reports or feature requests
  • Check the Wiki for detailed documentation
  • Join our Discussions for community support

🚧 Roadmap

  • Docker support
  • Script scheduling (cron-like functionality)
  • Resource usage graphs
  • Script dependencies management
  • Email/webhook notifications
  • Dark mode theme
  • Multi-user support with authentication

Made with ❀️ by the Python community