Skip to main content

Ensure only one instance of your process runs at a time.

Project description

Runce

🚀 The One-and-Done Process Wrangler

"Runce and done! No repeats, no retreats!" 🏃‍♂️💨
🔒 Guaranteed Singleton Execution • 📊 Process Tracking • ⏱️ Lifecycle Management

runce PyPI version fury.io

☕ Support

If you find this project helpful, consider supporting me:

ko-fi

Features ✨

  • 🚫 No Duplicates: Each command runs exactly once per unique ID
  • 📝 Process Tracking: View all managed processes with status
  • ⏱️ Execution Time: Track how long processes have been running
  • 📂 Log Management: Automatic stdout/stderr capture
  • 🛑 Clean Termination: Proper process killing

Installation 📦

pip install runce

Usage

runce <command> [options] [arguments]

Commands

run

Runs a new singleton process.

runce run [options] ARG...

Options:

  • --id <run_id>: Unique run identifier (required).
  • --working-directory <cwd>: Working directory for the command.
  • -t <tail> / --tail <tail>: Tail the output (n lines). Use -t -1 to print the entire output.
  • --overwrite: Overwrite existing entry if it exists.
  • --run-after <command>: Run a command after the main command finishes.

Example:

runce run --id my-unique-task sleep 60

ls / list

Lists all managed processes.

runce ls [options]

Options:

  • -f <format> / --format <format>: Format of the output line (see examples below).

Example:

runce ls
runce ls -f "{pid}\t{name}\t{command}"

status

Checks the status of processes.

runce status [options] [ID...]

Options:

  • -f <format> / --format <format>: Format of the output line.

Example:

runce status my-unique-task

kill

Kills running processes.

runce kill [options] ID...

Options:

  • --dry-run: Perform a dry run (don't actually kill).
  • --remove: Remove the entry after killing.

Example:

runce kill my-unique-task

clean

Cleans up entries for non-existing processes.

runce clean [ID...]

Example:

runce clean

tail

Tails the output of processes.

runce tail [options] [ID...]

Options:

  • -n <lines> / --lines <lines>: Number of lines to tail.
  • --header <format>: Header format.
  • -x / --only-existing: Only show existing processes.
  • -t / --tab: Prefix tab space to each line.

Example:

runce tail my-unique-task
runce tail -n 20 my-unique-task

restart

Restarts a process.

runce restart [options] ID...

Options:

  • -t <tail> / --tail <tail>: Tail the output after restarting.

Example:

runce restart my-unique-task

Examples 💡

1. Running a Background Service

runce run --id api-server -- python api.py

2. Checking Running Processes

$ runce list
PID     NAME        STATUS      ELAPSED    COMMAND
1234    api-server   Running  01:23:45   python api.py
5678    worker       Stopped  00:45:30   python worker.py

3. Preventing Duplicates

$ runce run --id daily-job -- python daily.py
🚀 Started: PID:5678( Running) daily-job

$ runce run --id daily-job -- python daily.py
🚨 Already running: PID:5678( Running) daily-job

Formats

The -f / --format option in the ls and status commands allows you to customize the output format. You can use the following placeholders:

  • {pid}: Process ID
  • {name}: Run ID / Name
  • {pid_status}: Process status ("✅ Running" or "👻 Absent")
  • {elapsed}: Elapsed time
  • {command}: The command being executed

How It Works

RunCE stores process information in JSON files within a temporary directory (/tmp/runce.v1 on Linux). Before starting a new process, it checks for existing entries with the same ID to prevent duplicates.

Development 🏗️

# Install in development mode
pip install -e .

# Run tests
pytest

# Lint code
flake8 runce

License: GPL v3

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

runce-0.1.9.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

runce-0.1.9-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file runce-0.1.9.tar.gz.

File metadata

  • Download URL: runce-0.1.9.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for runce-0.1.9.tar.gz
Algorithm Hash digest
SHA256 943e2e36492c2d71a2ee92c7ec189d60a59a43b5bd6840859cffccf548a44578
MD5 a16e211c0e3b16e3e4a77c9c76b9b4b4
BLAKE2b-256 41d8b5f31ed107828f116c8da141c7980cf8180e97ea25c9a2c95c00dd7eb29b

See more details on using hashes here.

File details

Details for the file runce-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: runce-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for runce-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 4cce748419ffbff8830f1e9619b983317b2985c52ac71ecf9325bc737d083747
MD5 22386833a3f9a59ed89e4cae1e7765e4
BLAKE2b-256 f32a5ba0dddd9699e4190016bd55d4c5b0a6476abb95ad9a28da3b8f799b2ec6

See more details on using hashes here.

Supported by

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