update
This commit is contained in:
19
ts/cli/registration/daemon-check.ts
Normal file
19
ts/cli/registration/daemon-check.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { tspmIpcClient } from '../../classes.ipcclient.js';
|
||||
|
||||
/**
|
||||
* Preflight the daemon if required. Uses getDaemonStatus() which is safe and cheap:
|
||||
* it only connects if the PID file is valid.
|
||||
*/
|
||||
export async function ensureDaemonOrHint(requireDaemon: boolean | undefined, actionLabel?: string): Promise<boolean> {
|
||||
if (requireDaemon === false) return true; // command does not require daemon
|
||||
const status = await tspmIpcClient.getDaemonStatus();
|
||||
if (!status) {
|
||||
// Same hint as handleDaemonError, but early and consistent
|
||||
console.error(`Error: Cannot ${actionLabel || 'perform action'} - TSPM daemon is not running.`);
|
||||
console.log('\nTo start the daemon, run one of:');
|
||||
console.log(' tspm daemon start - Start for this session only');
|
||||
console.log(' tspm enable - Enable as system service (recommended)');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user