Keep the site up when the cleanup job is killed
The cleanup job stops the server, puts the files back and starts it again. On a slow disk that took minutes, and on 2026-10-28 the job was killed while the server was down: the task of the server only starts it again when it failed, never when it was stopped, so the site was down until the box was power-cycled. The job now puts the home directory, the four texts and the permissions of the installation back while the server runs, and only stops it for the protected copy, which cannot be replaced while the server holds it open. A new task, "KiK watch the server", starts the server every two minutes when nothing listens on port 22 and the cleanup job is not running. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
f4113033ac
commit
5a885e3781
1 changed files with 99 additions and 56 deletions
|
|
@ -58,19 +58,27 @@ user as well; everything else in the installation is theirs.
|
|||
|
||||
## The cleanup tasks
|
||||
|
||||
Two scheduled tasks run as SYSTEM, both at startup, and the user cannot stop either:
|
||||
Three scheduled tasks run as SYSTEM, all at startup, and the user cannot stop any of them:
|
||||
|
||||
- `KiK sshd` runs the sshd from `C:\msys2\opt\kik`. It replaces the installation's own `msys2-sshd` service, which
|
||||
is disabled.
|
||||
- `KiK restore shell files` runs every 30 minutes and rebuilds the protected copy from its trusted originals,
|
||||
re-applies the permissions, and puts the home directory, the shell configuration, the website's key and the four
|
||||
texts back. Its second job is to best-effort revert other mockery and bring a fresh server to the expected state.
|
||||
- `KiK watch the server` runs every two minutes and starts the server when nothing listens on port 22. The task of
|
||||
the server only starts it again when it failed, never when it was stopped, so a cleanup job that is killed while
|
||||
it has the server stopped would otherwise take the site down with it.
|
||||
|
||||
The cleanup job also restarts the server when nobody is connected, and when the server does not listen at all:
|
||||
it comes back by itself if it died, it takes over a server that was left behind, and it picks up the programs that
|
||||
were just restored. A session that is open keeps the port, so a server that is started now could not bind it, and
|
||||
the job never disturbs a session.
|
||||
|
||||
The server is only down for the short part of the job that needs it down: the protected copy cannot be replaced
|
||||
while the server holds it open. Everything else - the home directory, the four texts, the permissions of the
|
||||
installation - is put back while the server runs, because on a slow disk that takes minutes and the site should
|
||||
have a shell the whole time.
|
||||
|
||||
The task that runs the server ignores a start while it thinks it is still running, so a start that is dropped
|
||||
leaves the site without a shell. The cleanup job therefore tries three times, killing the processes of the task
|
||||
in between, before it gives up.
|
||||
|
|
|
|||
Loading…
Reference in a new issue