1.7 KiB
1.7 KiB
TSPM SmartDaemon Service Management Refactor
Problem
Currently TSPM auto-spawns the daemon as a detached child process, which is improper daemon management. It should use smartdaemon for all lifecycle management and never spawn processes directly.
Solution
Refactor to use SmartDaemon for proper systemd service integration.
Implementation Tasks
Phase 1: Remove Auto-Spawn Behavior
- Remove spawn import from ts/classes.ipcclient.ts
- Delete startDaemon() method from IpcClient
- Update connect() to throw error when daemon not running
- Remove auto-reconnect logic from request() method
Phase 2: Create Service Manager
- Create new file ts/classes.servicemanager.ts
- Implement TspmServiceManager class
- Add getOrCreateService() method
- Add enableService() method
- Add disableService() method
- Add getServiceStatus() method
Phase 3: Update CLI Commands
- Add 'enable' command to CLI
- Add 'disable' command to CLI
- Update 'daemon start' to work without systemd
- Add 'daemon start-service' internal command for systemd
- Update all commands to handle missing daemon gracefully
- Add proper error messages with hints
Phase 4: Update Documentation
- Update help text in CLI
- Update command descriptions
- Add service management section
Phase 5: Testing
- Test enable command
- Test disable command
- Test daemon commands
- Test error handling when daemon not running
- Build and verify TypeScript compilation
Migration Notes
- Users will need to run
tspm enable
once after update - Existing daemon instances will stop working
- Documentation needs updating to explain new behavior