Metadata-Version: 2.4
Name: konstant
Version: 0.1.0
Summary: A lightweight Python-native service manager.
License: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer>=0.12
Requires-Dist: tomli>=2.0
Requires-Dist: python-dotenv>=1.0
Requires-Dist: pywin32>=306; sys_platform == "win32"
Requires-Dist: watchdog>=4.0
Requires-Dist: psutil>=5.9
Requires-Dist: rich>=13.0
Dynamic: license-file

# konstant

A lightweight Python process manager for Windows. Think **PM2** but Python-native and without the Node dependency.

## Features

- Manage long-running Python processes via a simple CLI
- Automatic restart with configurable backoff protection
- Log capture with rotation
- Optional Windows service registration (survives reboots)
- No daemon required — state is stored in flat JSON files

## Installation

```bash
pip install -e .
```

## Quick Start

1. Create a `konstant.toml` in your working directory:

```toml
[services.my-worker]
script = "worker.py"
interpreter = "python"
cwd = "C:/projects/myapp"
env_file = ".env"
autorestart = true
max_restarts = 10
restart_delay = 5
```

2. Start your services:

```bash
konstant start              # start all services
konstant start my-worker    # start a specific service
```

## CLI Commands

```
konstant start [name]          Start service(s)
konstant stop [name]           Stop service(s)
konstant restart [name]        Restart service(s)
konstant status [name]         Show pid, uptime, restart count, status
konstant logs [name]           Tail logs (default: last 50 lines)
konstant logs [name] --follow  Stream logs live
konstant install [name]        Register as Windows service (survives reboot)
konstant uninstall [name]      Remove Windows service registration
```

## Configuration

See `konstant.toml` for all available options:

| Key             | Type   | Default    | Description                         |
|-----------------|--------|------------|-------------------------------------|
| `script`        | str    | *required* | Path to the Python script to run    |
| `interpreter`   | str    | `"python"` | Python interpreter to use           |
| `cwd`           | str    | `"."`      | Working directory for the process   |
| `env_file`      | str    | `""`       | Path to a `.env` file to load       |
| `autorestart`   | bool   | `true`     | Restart on crash                    |
| `max_restarts`  | int    | `10`       | Max restarts within a 60s window    |
| `restart_delay` | int    | `5`        | Seconds to wait before restarting   |
| `args`          | list   | `[]`       | Extra arguments passed to the script|

## License

MIT
