Merge pull request #1418 from IYENTeam/fix/enable-linger-clean

fix: enable loginctl linger so user service survives SSH logout
This commit is contained in:
gavrielc
2026-03-25 22:27:17 +02:00
committed by GitHub

View File

@@ -266,6 +266,20 @@ WantedBy=${runningAsRoot ? 'multi-user.target' : 'default.target'}`;
// Kill orphaned nanoclaw processes to avoid channel connection conflicts // Kill orphaned nanoclaw processes to avoid channel connection conflicts
killOrphanedProcesses(projectRoot); killOrphanedProcesses(projectRoot);
// Enable lingering so the user service survives SSH logout.
// Without linger, systemd terminates all user processes when the last session closes.
if (!runningAsRoot) {
try {
execSync('loginctl enable-linger', { stdio: 'ignore' });
logger.info('Enabled loginctl linger for current user');
} catch (err) {
logger.warn(
{ err },
'loginctl enable-linger failed — service may stop on SSH logout',
);
}
}
// Enable and start // Enable and start
try { try {
execSync(`${systemctlPrefix} daemon-reload`, { stdio: 'ignore' }); execSync(`${systemctlPrefix} daemon-reload`, { stdio: 'ignore' });
@@ -301,6 +315,7 @@ WantedBy=${runningAsRoot ? 'multi-user.target' : 'default.target'}`;
UNIT_PATH: unitPath, UNIT_PATH: unitPath,
SERVICE_LOADED: serviceLoaded, SERVICE_LOADED: serviceLoaded,
...(dockerGroupStale ? { DOCKER_GROUP_STALE: true } : {}), ...(dockerGroupStale ? { DOCKER_GROUP_STALE: true } : {}),
LINGER_ENABLED: !runningAsRoot,
STATUS: 'success', STATUS: 'success',
LOG: 'logs/setup.log', LOG: 'logs/setup.log',
}); });