1
+ # Shentry
2
+
3
+ [ ![ Build Status] ( https://travis-ci.com/EasyPost/shentry.svg?branch=master )] ( https://travis-ci.com/EasyPost/shentry )
4
+ [ ![ Coverage Status] ( https://coveralls.io/repos/github/EasyPost/shentry/badge.svg )] ( https://coveralls.io/github/EasyPost/shentry )
5
+ [ ![ Version] ( https://img.shields.io/github/v/tag/EasyPost/shentry )] ( https://github.com/EasyPost/shentry/releases )
6
+
1
7
** Shentry** is a single-file Python script which will run the wrapped
2
8
command and, if it fails, post an event to Sentry. By default, if the
3
9
wrapped script succeeds (exists with code 0), stdout/stderr are squashed,
4
10
similarly to [ shuck] ( https://github.com/thwarted/shuck ) or
5
11
[ chronic] ( https://joeyh.name/code/moreutils/ ) . It also always exits with
6
12
status 0 if events are able to be sent to Sentry.
7
13
8
- It reads its configuration from the environment variable ` $SHELL_SENTRY_DSN `
9
- and, if such a variable is found, removes it from the environment before
10
- calling the wrapped program. If that environment variable is not present, shentry will look
11
- for ` $SENTRY_DSN ` (and similarly remove it from the environment).
12
- If you need to use SENTRY_DSN inside your project code, make sure to set both.
13
- You may also in that case want to put a top-level try/except around your whole
14
- program to prevent uncaught exceptions from trigging both your in-process sentry sdk
15
- and also your extra-process shentry, since you very likely only want one or the other.
16
- If neither of the environment variables are present or both
17
- are empty, shentry will try to read a DSN from ` /etc/shentry_dsn ` . If no DSN
18
- can be found, the wrapped will have normal behavior (stdout/stderr will go
19
- to their normal file descriptors, exit code will be passed through, etc).
20
-
21
- This software should be compatible with Python 2.6, 2.7, and 3.5+;
22
- that is to say, you should be able to run it just about anywhere.
23
-
24
- [ ![ Build Status] ( https://travis-ci.com/EasyPost/shentry.svg?branch=master )] ( https://travis-ci.com/EasyPost/shentry )
25
-
26
-
27
14
## Installation
28
15
29
16
Put the file [ ` shentry.py ` ] ( shentry.py ) anywhere in your ` $PATH ` under the
@@ -34,27 +21,46 @@ If the `requests` library is available, it will be used; otherwise, the standard
34
21
either ` $SHELL_SENTRY_PROXY ` or the contents of ` /etc/shentry_proxy ` can be
35
22
used to configure an outbound proxy.
36
23
37
- The ` setup.py ` in this directory only exists for ` tox ` to work (and run unit
38
- tests). Don't bother using it; just copy ` shentry.py ` wherever you want it.
24
+ The ` setup.py ` in this directory only exists for this project's dev tooling. To get
25
+ Shentry working on your machine, simply copy ` shentry.py ` wherever you need it.
39
26
40
27
## Usage
41
28
42
29
You might want a crontab that looks something like the following:
43
30
44
- SHELL_SENTRY_DSN=https://pub:priv@app.getsentry.com/id
31
+ ``` sh
32
+ SHELL_SENTRY_DSN=https://pub:priv@app.getsentry.com/id
45
33
46
- 15 * * * * /usr/local/bin/shentry /usr/local/bin/run-periodic-scripts
34
+ 15 * * * * /usr/local/bin/shentry /usr/local/bin/run-periodic-scripts
35
+ ```
47
36
48
37
You can also make shentry your ` $SHELL ` and wrap all commands in it:
49
38
50
- SHELL_SENTRY_DSN=https://pub:priv@app.getsentry.com/id
51
- SHELL=/usr/local/bin/shentry
39
+ ``` sh
40
+ SHELL_SENTRY_DSN=https://pub:priv@app.getsentry.com/id
41
+ SHELL=/usr/local/bin/shentry
52
42
53
- 15 * * * * /usr/local/bin/run-periodic-scripts
54
- 7 1 * * * /usr/local/bin/run-daily-scripts
43
+ 15 * * * * /usr/local/bin/run-periodic-scripts
44
+ 7 1 * * * /usr/local/bin/run-daily-scripts
45
+ ```
55
46
56
47
In this case, it will run the wrapped commands through ` /bin/sh ` (otherwise, it will honor ` $SHELL ` ).
57
48
49
+ ### Environment Variables
50
+
51
+ Shentry reads its configuration from the environment variable ` $SHELL_SENTRY_DSN `
52
+ and, if such a variable is found, removes it from the environment before
53
+ calling the wrapped program. If that environment variable is not present, shentry will look
54
+ for ` $SENTRY_DSN ` (and similarly remove it from the environment).
55
+ If you need to use ` SENTRY_DSN ` inside your project code, make sure to set both.
56
+ You may also in that case want to put a top-level try/except around your whole
57
+ program to prevent uncaught exceptions from trigging both your in-process sentry sdk
58
+ and also your extra-process shentry, since you very likely only want one or the other.
59
+ If neither of the environment variables are present or both
60
+ are empty, shentry will try to read a DSN from ` /etc/shentry_dsn ` . If no DSN
61
+ can be found, the wrapped will have normal behavior (stdout/stderr will go
62
+ to their normal file descriptors, exit code will be passed through, etc).
63
+
58
64
## License
59
65
60
66
This software is licensed under the ISC License, the full text of which can be found at [ LICENSE.txt] ( LICENSE.txt ) .
0 commit comments