Multi-Instance Daemon Support
Spacedrive CLI now supports running multiple daemon instances simultaneously, enabling local testing of device pairing and other multi-device features.Overview
Multiple daemon instances allow you to:- Test device pairing locally by running two instances
- Simulate multi-device scenarios on a single machine
- Isolate different development/testing environments
- Run production and development daemons side-by-side
Usage
Starting Multiple Instances
Targeting Specific Instances
Use the--instance flag to target commands to specific daemon instances:
Instance Management
Auto-Start Configuration
On macOS, you can configure instances to start automatically on login:--data-dir and --instance flags automatically. Logs write to ~/Library/Application Support/spacedrive/logs/daemon.out.log and daemon.err.log.
Device Pairing Example
Test device pairing locally using two instances:Architecture
Instance Isolation
Each instance has completely isolated:- Socket paths:
spacedrive.sock,spacedrive-alice.sock,spacedrive-bob.sock - PID files:
spacedrive.pid,spacedrive-alice.pid,spacedrive-bob.pid - Data directories:
data/sd-cli-data/,data/sd-cli-data/instance-alice/ - CLI state: Separate
cli_state.jsonper instance
File Structure
Development Workflow
Testing Pairing Protocol
Instance Cleanup
Backwards Compatibility
The implementation maintains full backwards compatibility:- All existing commands work unchanged with the default instance
- No breaking changes to CLI interface
- Default instance behavior is identical to single-instance mode
Implementation Notes
- Instance names must be valid filenames (no special characters)
- Socket discovery happens automatically via filesystem scanning
- Daemon startup checks for instance conflicts
- Each instance runs independently with separate process trees
