Skip to main content

CronBark Python SDK & CLI — 크론잡 모니터링을 위한 간편 연동 도구

Project description

CronBark Python SDK

Python SDK and CLI for CronBark — monitor any cron job with a single decorator.

Preview / Alpha. This SDK is in preview and the CronBark SaaS service is launching soon. The public API may change in backwards-incompatible ways before the 1.0 release.

Install

pip install cronbark

Requires Python 3.9+.

Quickstart

Get an API token from your CronBark dashboard, then pick whichever style fits your job best.

1. Context manager

Wrap any block of code — start is sent on entry, and success or fail (with the traceback) is sent on exit.

import cronbark

cronbark.configure(token="YOUR_TOKEN")

with cronbark.monitor():
    run_backup()

2. Decorator

Instrument an existing function in one line.

import cronbark

@cronbark.job("YOUR_TOKEN")
def generate_report():
    ...

3. CLI — wrap any command

The easiest way to monitor an existing cron entry without touching its source:

cronbark exec --token YOUR_TOKEN "python backup.py"

Use it directly in crontab:

# Before
0 * * * * /usr/bin/python3 /opt/scripts/backup.py

# After
0 * * * * cronbark exec --token YOUR_TOKEN "/usr/bin/python3 /opt/scripts/backup.py"

The CLI captures stdout/stderr, forwards them to CronBark, and exits with the same status code as the wrapped command.

Configuration

The SDK reads configuration from environment variables by default:

Variable Purpose Default
CRONBARK_TOKEN Your job's API token (none — required)
CRONBARK_URL API base URL override (self-hosted, staging, etc.) https://api.cronbark.com

You can also configure the SDK programmatically:

import cronbark

cronbark.configure(
    token="YOUR_TOKEN",
    base_url="https://api.cronbark.com",  # optional
    timeout=10,                            # seconds, optional
)

Public API

Top-level functions exported from the cronbark package:

Symbol Description
configure(token, base_url, timeout) Set global SDK configuration.
monitor(token=None) Context manager — auto start / success / fail.
job(token=None) Decorator wrapping a function with monitor.
ping(token=None) One-shot start + success.
start(token=None) Report execution start.
success(token=None, output=None, metrics=None) Report success.
fail(token=None, error_message=None, output=None) Report failure.
tick(token=None) Heartbeat — report success without a prior start.

CLI commands (cronbark --help):

cronbark exec --token TOKEN "<command>"   # wrap and run a command
cronbark ping TOKEN                     # one-shot start+success
cronbark start TOKEN
cronbark success TOKEN
cronbark fail TOKEN --msg "..."
cronbark tick TOKEN
cronbark discover                       # scan local crontab

All HTTP calls are best-effort: network errors are swallowed and returned as {"status": "error", "message": "..."} so an unreachable monitoring service will never break your job.

Links

License

MIT — see LICENSE.

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

cronbark-0.0.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

cronbark-0.0.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file cronbark-0.0.1.tar.gz.

File metadata

  • Download URL: cronbark-0.0.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cronbark-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a09ab6482dad266731c3393f58e3df8610e17944b0543b2ed29e5915b63e5e9d
MD5 0d4dae178d3f400e707bbff8e635d38d
BLAKE2b-256 51b4b27d871d1b7e3dd8deb6ea59f15252e15fe0fac81913715ddc2642425172

See more details on using hashes here.

Provenance

The following attestation bundles were made for cronbark-0.0.1.tar.gz:

Publisher: release.yml on wookja-0/cronbark-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cronbark-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: cronbark-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cronbark-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d575fdb17a1f6990d8398d8dc4325f4f3c54dcaff257596de0f4f1be681dfdc1
MD5 fd4884f0e3f18b72fd8ae6fac534c749
BLAKE2b-256 7e64af7b4bbf0ff079f9586117d33d141e066006b5adec5cbdbc49971f6e0800

See more details on using hashes here.

Provenance

The following attestation bundles were made for cronbark-0.0.1-py3-none-any.whl:

Publisher: release.yml on wookja-0/cronbark-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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