cron sentry是一个命令行包装器,它向sentry报告不成功的运行(https://www.getsentry.com)
cron-sentr的Python项目详细描述
cron sentry是一个python命令行包装器,它将错误报告给Sentry(使用raven) 如果被调用的脚本退出了一个非零的状态。
安装
pip install cron-sentry
用法
$ cron-sentry --help usage: cron-sentry [-h] [--dsn SENTRY_DSN] [-M STRING_MAX_LENGTH] [--quiet] [--report-all] [--version] cmd [arg ...] Wraps commands and reports those that fail to Sentry. positional arguments: cmd The command to run optional arguments: -h, --help show this help message and exit --dsn SENTRY_DSN Sentry server address -M STRING_MAX_LENGTH, --string-max-length STRING_MAX_LENGTH, --max-message-length STRING_MAX_LENGTH The maximum characters of a string that should be sent to Sentry (defaults to 4096) -q, --quiet Suppress all command output --version show program's version number and exit --report-all Report to Sentry even if the task has succeeded The Sentry server address can also be specified through the SENTRY_DSN environment variable (and the --dsn option can be omitted).
可以通过环境向哨兵发送额外的信息 变量(以CRON_SENTRY_EXTRA_作为前缀),例如:
$ export CRON_SENTRY_EXTRA_env=production $ cron-sentry my-program
示例
$ crontab -e
SENTRY_DSN=https://<your_key>:<your_secret>@app.getsentry.com/<your_project_id> 0 4 * * * cron-sentry my-process --arg arg2
注释
- 如果命令输出unicode,则可能需要向python发出信号,表明stdin/stdout/stderr是utf-8编码的:
PYTHONIOENCODING=utf-8 SENTRY_DSN=https://<your_key>:<your_secret>@app.getsentry.com/<your_project_id> 0 4 * * * cron-sentry my-process --arg arg2
许可证
这个项目最初是由mediacore technologies作为raven-cron开始的。
MediaCore Technologies(麻省理工学院许可证)2013年原始版权。 Yipit公司(麻省理工学院许可证)2015年版权所有。