-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from skysea04/dev
Add health check and change README
- Loading branch information
Showing
5 changed files
with
44 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# Snap Up THSR (Work in progress) | ||
# Snap Up THSR | ||
|
||
__!!此專案為純研究用途,請勿用於不當交易行為!!__ | ||
|
||
這是一份自動化高鐵購票系統的後端程式碼 | ||
這是一份自動化高鐵購票系統,使用 Django 後台進行使用者管理與訂票提單系統,協助完成訂票的最後一哩路。 | ||
|
||
使用技術: | ||
- Django | ||
- beautifulsoup4 | ||
|
||
本系統已實踐會員系統與基礎購票功能,未來將會陸續新增以下功能: | ||
1. 多種類的自動購票策略 | ||
2. 疏運期間售票時間調整 | ||
2. 疏運期間售票提醒 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
from django.core.mail import send_mail | ||
from basis.logger import log | ||
|
||
|
||
def count_lines(filename: str) -> int: | ||
with open(filename, 'r') as file: | ||
lines = file.readlines() | ||
return len(lines) | ||
|
||
|
||
def clear_log(filename: str): | ||
with open(filename, 'w') as file: | ||
file.write('') | ||
|
||
|
||
LOG_PATH = '/src/logs/django.log' | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Check the health of the application' | ||
|
||
def handle(self, *args, **options): | ||
lines = count_lines(LOG_PATH) | ||
if lines: | ||
clear_log(LOG_PATH) | ||
log.info('Snap up health check: OK') | ||
return | ||
|
||
send_mail( | ||
subject='Snap Up THSR 工作排程警告', | ||
message='Snap Up THSR 的工作排程已久無運作,記得去檢查一下!', | ||
from_email=settings.EMAIL_HOST_USER, | ||
recipient_list=['[email protected]'], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters