Deploy to the handset from the cluster
CI builds an arm64 image (compositor, host, chandra-remote, modules) and deploys the updater pod that installs it on the phone. chandra-remote updates go in live (SIGUSR2 restarts it in place); the compositor waits for an idle, locked phone or an approval, and a locked session restarts locked. Host tests: the launcher no longer draws its label in a narrow panel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d2e00b4658
commit
2aa3de5741
14 files changed
+675
-2
No files matched your search
@@ -21,12 +21,19 @@
|
||||
|
||||
static volatile sig_atomic_t g_running = 1;
|
||||
static volatile sig_atomic_t g_reload = 0;
|
||||
static volatile sig_atomic_t g_reexec = 0;
|
||||
|
||||
static void on_term(int sig) {
|
||||
(void)sig;
|
||||
g_running = 0;
|
||||
}
|
||||
|
||||
static void on_usr2(int sig) {
|
||||
(void)sig;
|
||||
g_reexec = 1;
|
||||
g_running = 0;
|
||||
}
|
||||
|
||||
static void on_hup(int sig) {
|
||||
(void)sig;
|
||||
g_reload = 1;
|
||||
@@ -740,6 +747,11 @@ int main(int argc, char **argv) {
|
||||
signal(SIGINT, on_term);
|
||||
signal(SIGTERM, on_term);
|
||||
signal(SIGHUP, on_hup);
|
||||
/* SIGUSR2: restart in place from the installed binary (an update), same pid and arguments. */
|
||||
char self_path[512];
|
||||
ssize_t self_len = readlink("/proc/self/exe", self_path, sizeof self_path - 1);
|
||||
self_path[self_len > 0 ? self_len : 0] = 0;
|
||||
if (self_path[0]) signal(SIGUSR2, on_usr2);
|
||||
|
||||
/* Record PID for `chandra-remote status` / `passwd`. */
|
||||
{
|
||||
@@ -870,6 +882,12 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
pthread_mutex_unlock(&app.osk_mu);
|
||||
ctl_close(&app.ctl);
|
||||
if (g_reexec) {
|
||||
fprintf(stderr, "chandra-remote: restarting for an update\n");
|
||||
close_range(3, ~0U, CLOSE_RANGE_CLOEXEC); /* clients' sockets too: they reconnect */
|
||||
execv(self_path, argv);
|
||||
fprintf(stderr, "chandra-remote: exec %s: %s\n", self_path, strerror(errno));
|
||||
}
|
||||
unlink(pid_path);
|
||||
return 0;
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import json
|
||||
import mmap
|
||||
import os
|
||||
import shutil
|
||||
import signal
|
||||
import socket
|
||||
import struct
|
||||
import subprocess
|
||||
@@ -831,6 +832,27 @@ class RemoteTests(unittest.TestCase):
|
||||
self.assertEqual(self.clip_request("POST", b"y", {**hdr, "Cookie": "chandra_remote=" + tok})[0], 200)
|
||||
self.assertEqual(self.ctl.clips, [("text/plain", b"x"), ("text/plain", b"y")])
|
||||
|
||||
def test_09_sigusr2_restarts_in_place(self):
|
||||
self.start_daemon(auth="none")
|
||||
ws, status_line, _, _ = ws_connect("127.0.0.1", self.web_port)
|
||||
self.assertIn("101", status_line)
|
||||
ws.settimeout(5)
|
||||
pid = self.proc.pid
|
||||
self.proc.send_signal(signal.SIGUSR2)
|
||||
while ws.recv(65536): # the client is let go, so it can reconnect
|
||||
pass
|
||||
ws.close()
|
||||
deadline = time.time() + 5
|
||||
while time.time() < deadline:
|
||||
try:
|
||||
if self.clip_request("GET")[0] == 200:
|
||||
break
|
||||
except OSError:
|
||||
time.sleep(0.05)
|
||||
self.assertIsNone(self.proc.poll())
|
||||
self.assertEqual(self.proc.pid, pid)
|
||||
self.assertEqual(self.clip_request("GET"), (200, {"ok": True, "serial": 0}))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user