@cocorograph/hub-agent 0.7.65 → 0.7.66
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/package.json +1 -1
- package/scripts/install.ps1 +13 -13
package/package.json
CHANGED
package/scripts/install.ps1
CHANGED
|
@@ -240,23 +240,23 @@ function Set-Systemd($distro) {
|
|
|
240
240
|
# Register a logon task that keeps the distro ALIVE (so its systemd --user
|
|
241
241
|
# hub-agent stays online).
|
|
242
242
|
#
|
|
243
|
-
#
|
|
244
|
-
#
|
|
245
|
-
# `SIGTERM shutting down`
|
|
246
|
-
#
|
|
247
|
-
#
|
|
243
|
+
# The old impl used `wsl ... /bin/true` to wake the distro only briefly. WSL2's
|
|
244
|
+
# idle shutdown then collapsed the whole distro within tens of seconds (agent.log
|
|
245
|
+
# shows `SIGTERM shutting down` and `wsl -l -v` goes Stopped), so hub-agent also
|
|
246
|
+
# stopped and went offline. systemd --user + linger only works "while the distro
|
|
247
|
+
# is running", so we need a resident process that keeps the distro awake.
|
|
248
248
|
#
|
|
249
|
-
#
|
|
250
|
-
#
|
|
249
|
+
# Fix: run `sleep infinity` inside WSL for the whole logon session to keep the
|
|
250
|
+
# distro up. Also start hub-agent.service (idempotent when already enabled+linger).
|
|
251
251
|
function Register-BootTask($distro, $user) {
|
|
252
252
|
Write-Step "Registering autostart on logon (Task Scheduler, keep-alive)"
|
|
253
|
-
# distro
|
|
253
|
+
# keep-alive that holds the distro up. systemctl start is idempotent (no-op if active).
|
|
254
254
|
$keepalive = "systemctl --user start hub-agent.service 2>/dev/null; exec sleep infinity"
|
|
255
255
|
$action = New-ScheduledTaskAction -Execute "wsl.exe" `
|
|
256
256
|
-Argument "-d $distro -u $user -- bash -lc `"$keepalive`""
|
|
257
257
|
$trigger = New-ScheduledTaskTrigger -AtLogOn
|
|
258
|
-
# ExecutionTimeLimit=0
|
|
259
|
-
# keep-alive
|
|
258
|
+
# ExecutionTimeLimit=0 for unlimited (default 72h would stop it and drop the distro).
|
|
259
|
+
# If the keep-alive ever exits, restart after 1 min up to 3 times. Multiple instances suppressed.
|
|
260
260
|
$set = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries `
|
|
261
261
|
-StartWhenAvailable -MultipleInstances IgnoreNew `
|
|
262
262
|
-RestartInterval (New-TimeSpan -Minutes 1) -RestartCount 3 `
|
|
@@ -333,14 +333,14 @@ function Main {
|
|
|
333
333
|
# --- autostart ---
|
|
334
334
|
Register-BootTask $distro $user
|
|
335
335
|
|
|
336
|
-
#
|
|
337
|
-
# distro
|
|
336
|
+
# Finish onlining at setup time: start the keep-alive task now and keep the
|
|
337
|
+
# distro up (hub-agent goes resident without waiting for re-logon).
|
|
338
338
|
Write-Step "Starting keep-alive now (online without re-logon)"
|
|
339
339
|
try {
|
|
340
340
|
Start-ScheduledTask -TaskName $TASK_NAME
|
|
341
341
|
Write-Ok "Keep-alive started; hub-agent should come online shortly"
|
|
342
342
|
} catch {
|
|
343
|
-
Write-Warn "Start-ScheduledTask failed ($($_.Exception.Message));
|
|
343
|
+
Write-Warn "Start-ScheduledTask failed ($($_.Exception.Message)); re-logon to start it"
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
Write-Host ""
|