thinkpool-pair 0.7.17 → 0.7.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account.mjs +12 -1
- package/package.json +1 -1
package/account.mjs
CHANGED
|
@@ -165,7 +165,18 @@ export async function runAccount(SUPABASE_URL, SUPABASE_ANON) {
|
|
|
165
165
|
const machine = os.hostname().replace(/\.local$/, '')
|
|
166
166
|
const acct = sb.channel(`tpacct:${session.user.id}`, { config: { presence: { key: machine }, broadcast: { self: false } } })
|
|
167
167
|
// Dashboard "Disconnect" → broadcast shutdown → clean exit (presence leaves, bar flips live).
|
|
168
|
-
|
|
168
|
+
// If we're the auto-restarting background service (launchd KeepAlive / systemd
|
|
169
|
+
// Restart=always sets AUTOUPDATE=1), a bare exit would be respawned ~2s later —
|
|
170
|
+
// so the toggle would appear to do nothing (presence leaves, then rejoins).
|
|
171
|
+
// Uninstall the account service FIRST so the supervisor won't restart us, then
|
|
172
|
+
// stop. Mirrors the per-room session-deleted guard in bridge.mjs.
|
|
173
|
+
acct.on('broadcast', { event: 'shutdown' }, async () => {
|
|
174
|
+
process.stderr.write('\n ◇ disconnect requested from the dashboard — stopping bridge.\n')
|
|
175
|
+
if (process.env.THINKPOOL_PAIR_AUTOUPDATE === '1') {
|
|
176
|
+
try { const svc = await import('./service.mjs'); svc.uninstallService(null) } catch { /* noop */ }
|
|
177
|
+
}
|
|
178
|
+
process.kill(process.pid, 'SIGTERM')
|
|
179
|
+
})
|
|
169
180
|
const pushPresence = () => { try { acct.track({ name: machine, version: VERSION, rooms: [...children.keys()], ts: Date.now() }) } catch { /* noop */ } }
|
|
170
181
|
await new Promise((res) => acct.subscribe((st) => { if (st === 'SUBSCRIBED') { pushPresence(); res() } }))
|
|
171
182
|
|