Reboot
Reboot after X-hour¶
Description: Reboot server to release resources component
Schedule: 55 9,13,19,23 * * *
Because the CRON will always to remember the component at the --:00
, so we extracted 5 min each.
Mechanism:
flowchart LR
subgraph slack[Slack]
ok_channel[Channel #server]
end
subgraph tserver[Target Server]
direction LR
subgraph reboot_progress[Reboot Progress]
direction LR
pre_release[Send pre-release] --> exec_reboot[Reboot] --> after_release[Send after-release]
end
subgraph auth[Authentication]
auth_vpn[VPN Gateway] --> auth_user[Authentication User]
end
auth_user -- trigger --> reboot_progress
end
subgraph gha[GitHub Actions]
schedule[Schedule] -- execute --> ghwf[Workflow]
end
ghwf --> tserver
tserver --> slack
The runner exection reboot required su
priviledges and using reboot
without the password interactive. So config this into the target server.
Note: the runner can't not be the same as the runner for component schedule
Structure metadata for reboot:
A. [Required] Identifier of the server:
- The IPv4 of server. E.g:
172.1.1.2
. The IP will be hashed when go to the Slack
Shortcut check in Linux (tested on Centos7)
-
By User: The username that exection the progress
-
Phase of reboot progress:
PRE_RELEASE
orREBOOT
C. [Optional] The uptime of server since that period
Capture using Python
import subprocess
output = subprocess.run(["uptime", '-s'], capture_output=True)
output.stdout.decode('utf-8').strip()
Verify timezone
ls -l /etc/localtime
# lrwxrwxrwx. 1 root root 38 Oct 14 2022 /etc/localtime -> ../usr/share/zoneinfo/Asia/Ho_Chi_Minh
time.tzname
return a tuple of two string: The first is the name of the local non-DST timezone, the second is the name of the local DST timezone.
In case of failure, the will be the mayday mayday message
to notification for maintainer.