Skip to content

Commit

Permalink
alarm email add human time
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Mar 23, 2024
1 parent 92bfa5d commit dc31881
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions app/Console/Commands/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ public function __construct()
*/
public function handle()
{
$interval = 100;
$diff = sprintf("*/%d * * * *", ceil($interval/60));
$diff = get_setting("system.alarm_email_receiver");
dd($diff);
}

Expand Down
3 changes: 3 additions & 0 deletions app/Repositories/CleanupRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public static function checkCleanup(): void
continue;
}
$receiverUid = get_setting("system.alarm_email_receiver");
do_log("receiverUid: $receiverUid");
if (empty($receiverUid)) {
$locale = Locale::getDefault();
$subject = self::getAlarmEmailSubject($locale);
Expand Down Expand Up @@ -282,7 +283,9 @@ private static function getAlarmEmailBody(Carbon $now, string $level, int $lastT
"level" => $level,
"last_time" => $lastTime > 0 ? Carbon::createFromTimestamp($lastTime)->toDateTimeString() : "",
"elapsed_seconds" => $lastTime > 0 ? $now->getTimestamp() - $lastTime : "",
"elapsed_seconds_human" => $lastTime > 0 ? mkprettytime($now->getTimestamp() - $lastTime) : "",
"interval" => $interval,
"interval_human" => mkprettytime($interval),
], $locale);
}
}
2 changes: 1 addition & 1 deletion resources/lang/en/cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
'disable_user_parked' => 'Disable inactive user accounts, parked.',
'destroy_disabled_account' => 'Timed physical deletion of disabled accounts',
'alarm_email_subject' => '[:site_name] background cleanup task exception',
'alarm_email_body' => 'Current time: :now_time, level :level, Last run time was: :last_time, it has been more than: :elapsed_seconds seconds since it was run, the set run interval is: :interval seconds, please check!',
'alarm_email_body' => 'Current time: :now_time, level :level, Last run time was: :last_time, it has been more than: :elapsed_seconds seconds(:elapsed_seconds_human) since it was run, the set run interval is: :interval seconds(:interval_human), please check!',
];
2 changes: 1 addition & 1 deletion resources/lang/zh_CN/cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
'disable_user_parked' => '定时封禁已挂起的非活跃账号.',
'destroy_disabled_account' => '定时物理删除已封禁账号',
'alarm_email_subject' => '[:site_name]后台清理任务异常',
'alarm_email_body' => '当前时间::now_time, 级别 :level 上次运行时间是::last_time,已经超过::elapsed_seconds 秒没有运行,设置的运行间隔是::interval 秒,请检查!',
'alarm_email_body' => '当前时间::now_time, 级别 :level 上次运行时间是::last_time,已经超过::elapsed_seconds 秒(:elapsed_seconds_human)没有运行,设置的运行间隔是::interval 秒(:interval_human),请检查!',
];
2 changes: 1 addition & 1 deletion resources/lang/zh_TW/cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
'disable_user_parked' => '定時封禁已掛起的非活躍賬號.',
'destroy_disabled_account' => '定時物理刪除已封禁賬號',
'alarm_email_subject' => '[:site_name]後臺清理任務異常',
'alarm_email_body' => '當前時間::now_time, 級別 :level 上次運行時間是::last_time,已經超過::elapsed_seconds 秒沒有運行,設置的運行間隔是::interval 秒,請檢查!',
'alarm_email_body' => '當前時間::now_time, 級別 :level 上次運行時間是::last_time,已經超過::elapsed_seconds 秒(:elapsed_seconds_human)沒有運行,設置的運行間隔是::interval 秒(:interval_human),請檢查!',
];

0 comments on commit dc31881

Please sign in to comment.