Skip to content

Commit

Permalink
configuration (#35)
Browse files Browse the repository at this point in the history
* feat: add configuration

* chore: use crontab instead of custom script

* doc: edit readme

* chore: change github.com/404 as its status is 200

---------

Co-authored-by: Domenico Blanco <[email protected]>
  • Loading branch information
Picred and domenicoblanco authored Nov 10, 2023
1 parent 1b41d9d commit 49b49f9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# Custom
config/settings.yaml
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
A simple Python script to verify if a service is up. Whenever the service falls, a message will be sent to a user/group/channel with Telegram

## How to use?
Just set two env variables:
- Just set two env variables:
- `QDBotToken`, your bot token
- `QDBotIDs`, the ID(s) the bot will use to communicate any downtime. It's possible to set multiple IDs, semicolon separated without any space

Expand All @@ -20,6 +20,16 @@ export QDBotIDs="10000000" # Single ID
export QDBotIDs="10000000;10000001;10000002" # Multiple IDs
```

### Run it every 5 minutes using crontab
- Open crontab using:
```bash
$ crontab -e
```
- Add the following line
```bash
*/5 * * * * cd /path/to/Healthcheck-bot/ && python3 src/main.py > checks.log 2> errors.log
```

## Write Unit Tests
In order to write Unit Tests, you have to put it inside `tests`.
There are many possibilities,
Expand Down
Empty file added config/settings.yaml.dist
Empty file.
12 changes: 10 additions & 2 deletions src/urls.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"get": ["https://duckduckgo.com/", "https://google.com/"],
"ping": ["https://duckduckgo.com/", "https://google.com/"]
"get": [
"https://api-opis.unictdev.org/",
"https://telegram.unictdev.org/",
"https://open-job-dmi.unictdev.org/"
],
"ping": [
"https://api-opis.unictdev.org/",
"https://telegram.unictdev.org/",
"https://open-job-dmi.unictdev.org/"
]
}
2 changes: 1 addition & 1 deletion tests/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
'func': main.check_ok,
'expected_res': False,
'arg': ('https://github.com/404',),
'arg': ('https://github.com/IDontThinkThisPageWillEverExist',),
'is_async': True
},
{
Expand Down

0 comments on commit 49b49f9

Please sign in to comment.