Compare commits

...

2 Commits

Author SHA1 Message Date
e02737abd1 fix behavior with infinite retries
All checks were successful
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Successful in 9s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Successful in 5s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to TestPyPI (push) Successful in 4s
Python package / lint (push) Successful in 7s
2024-09-14 17:50:59 -06:00
4671cf5fac get rid of default config path 2024-09-14 17:46:39 -06:00
2 changed files with 9 additions and 3 deletions

View File

@ -6,6 +6,8 @@ Yes, I know Gotify doesn't have "goat" in its name but it sounds like it.
## Configuration
Configuration lives in a TOML file which should have (at a minimum) the following:
```toml
server = "https://gotify.example.com"
app_token = "app_token_from_gotify"
@ -15,7 +17,7 @@ app_token = "app_token_from_gotify"
## Usage
```
goat_monitor --config ./config.toml --retries -1 -- <COMMAND TO MONITOR>
goat_monitor --config ./config.toml --retries 3 -- <COMMAND TO MONITOR>
```
The command can be any shell command including arbitrarily many options / arguments.

View File

@ -17,7 +17,8 @@ from goat_monitor._version import __version__ # type: ignore
@click.argument("command", nargs=-1, required=False, type=str)
@click.option(
"--config",
default="~/.config/goat_monitor.toml",
# default="~/.config/goat_monitor.toml",
required=True,
type=click.Path(path_type=Path),
help="Use a .toml configuration file",
)
@ -58,7 +59,8 @@ def wrap(command: List[str], config: Path, retries: int, version):
if retries < 0:
raise ValueError("Invalid number of retries specified")
for attempt in range(retries + 1):
attempt = 0
while attempt <= retries:
# run the command
result = subprocess.run(
" ".join(command),
@ -100,6 +102,8 @@ def wrap(command: List[str], config: Path, retries: int, version):
# only retry on failure
break
attempt += 1
sys.exit(result.returncode)