Skip to content

Commit

Permalink
Merge pull request #21 from masdzub/master
Browse files Browse the repository at this point in the history
refactor: make it clean code
  • Loading branch information
harsxv authored Sep 9, 2024
2 parents 718c02d + 6c26b67 commit a58cd00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM python:3-alpine
WORKDIR /usr/src/app

COPY checks.yaml ./
COPY history.html.theme ./
COPY incidents.md ./
COPY index.html.theme ./
COPY requirements.txt ./
COPY tinystatus.py ./
COPY checks.yaml \
history.html.theme \
incidents.md \
index.html.theme \
requirements.txt \
tinystatus.py ./

RUN pip install --no-cache-dir -r requirements.txt
CMD [ "python", "/usr/src/app/tinystatus.py" ]
13 changes: 6 additions & 7 deletions tinystatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ async def run_checks(checks):
background_tasks = {}
async with asyncio.TaskGroup() as tg:
for check in checks:
if check['type'] == 'http':
task = tg.create_task(check_http(check['host'], check['expected_code']), name=check['name'])
elif check['type'] == 'ping':
task = tg.create_task(check_ping(check['host']), name=check['name'])
elif check['type'] == 'port':
task = tg.create_task(check_port(check['host'], check['port']), name=check['name'])

task = tg.create_task(
check_http(check['host'], check['expected_code']) if check['type'] == 'http' else
check_ping(check['host']) if check['type'] == 'ping' else
check_port(check['host'], check['port']) if check['type'] == 'port' else None,
name=check['name']
)
if task:
background_tasks[check['name']] = task

Expand Down

0 comments on commit a58cd00

Please sign in to comment.