fix(daemon): Ensure TSPM runtime dir exists and improve daemon startup/debug output

This commit is contained in:
2025-08-28 16:29:41 +00:00
parent 6141b26530
commit ae4148c82f
5 changed files with 23 additions and 3 deletions

View File

@@ -1,5 +1,13 @@
# Changelog
## 2025-08-28 - 3.0.2 - fix(daemon)
Ensure TSPM runtime dir exists and improve daemon startup/debug output
- Create ~/.tspm directory before starting the daemon to avoid missing-directory errors
- Start daemon child process with stdio inherited when TSPM_DEBUG=true to surface startup errors during debugging
- Add warning and troubleshooting guidance when daemon process starts but does not respond (suggest checking socket file and using TSPM_DEBUG)
- Bump package version to 3.0.1
## 2025-08-28 - 3.0.0 - BREAKING CHANGE(daemon)
Refactor daemon and service management: remove IPC auto-spawn, add TspmServiceManager, tighten IPC/client/CLI behavior and tests

View File

@@ -1,6 +1,6 @@
{
"name": "@git.zone/tspm",
"version": "3.0.0",
"version": "3.0.1",
"private": false,
"description": "a no fuzz process manager",
"main": "dist_ts/index.js",

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tspm',
version: '3.0.0',
version: '3.0.2',
description: 'a no fuzz process manager'
}

View File

@@ -34,6 +34,10 @@ export class TspmDaemon {
public async start(): Promise<void> {
console.log('Starting TSPM daemon...');
// Ensure the TSPM directory exists
const fs = await import('fs/promises');
await fs.mkdir(paths.tspmDir, { recursive: true });
// Check if another daemon is already running
if (await this.isDaemonRunning()) {
throw new Error('Another TSPM daemon instance is already running');

View File

@@ -37,9 +37,10 @@ export function registerDaemonCommand(smartcli: plugins.smartcli.Smartcli) {
);
// Start daemon as a detached background process
// Use 'inherit' for stdio to see any startup errors when debugging
const daemonProcess = spawn(process.execPath, [daemonScript], {
detached: true,
stdio: 'ignore',
stdio: process.env.TSPM_DEBUG === 'true' ? 'inherit' : 'ignore',
env: {
...process.env,
TSPM_DAEMON_MODE: 'true',
@@ -62,6 +63,13 @@ export function registerDaemonCommand(smartcli: plugins.smartcli.Smartcli) {
'\nNote: This daemon will run until you stop it or logout.',
);
console.log('For automatic startup, use "tspm enable" instead.');
} else {
console.warn('\n⚠ Warning: Daemon process started but is not responding.');
console.log('The daemon may have crashed on startup.');
console.log('\nTo debug, try:');
console.log(' TSPM_DEBUG=true tspm daemon start');
console.log('\nOr check if the socket file exists:');
console.log(` ls -la ~/.tspm/tspm.sock`);
}
// Disconnect from the daemon after starting