Summary
Implement OS-level service management for ContextForge, enabling it to run as a managed system service with proper lifecycle management (start, stop, restart, enable, disable).
Motivation
Currently, ContextForge must be started manually or via container orchestration. For bare-metal or VM deployments, users need proper OS integration to:
- Auto-start on boot
- Graceful shutdown handling
- Service health monitoring
- Log integration with system journals
- Standard service management commands
Proposed Implementation
1. Systemd (Linux)
Create a systemd service unit file (contextforge.service):
Type=notify or Type=simple with proper readiness signaling
- Socket activation support (optional)
- Hardening options (PrivateTmp, NoNewPrivileges, etc.)
- Proper dependency ordering (After=network-online.target)
- Environment file support (
/etc/contextforge/contextforge.env)
- User/group configuration (run as non-root)
2. Launchd (macOS)
Create a launchd plist file (com.contextforge.gateway.plist):
- KeepAlive with proper restart policies
- StandardOutPath/StandardErrorPath for logging
- Environment variables support
- User agent or system daemon options
3. Windows Service (Optional)
Consider pywin32 or NSSM wrapper for Windows service support:
- Service registration and removal
- Start/stop/restart commands
- Event log integration
4. CLI Commands
Extend mcpgateway CLI with service management:
mcpgateway service install # Install service files
mcpgateway service uninstall # Remove service files
mcpgateway service start # Start the service
mcpgateway service stop # Stop the service
mcpgateway service restart # Restart the service
mcpgateway service status # Show service status
mcpgateway service enable # Enable auto-start on boot
mcpgateway service disable # Disable auto-start on boot
mcpgateway service logs # Show/tail service logs
5. Installation Scripts
scripts/install-service.sh for Linux/macOS
scripts/install-service.ps1 for Windows (if supported)
- Makefile targets:
make install-service, make uninstall-service
Configuration
Service configuration via environment or config file:
# /etc/contextforge/contextforge.env
MCPGATEWAY_USER=contextforge
MCPGATEWAY_GROUP=contextforge
MCPGATEWAY_WORKDIR=/var/lib/contextforge
MCPGATEWAY_CONFIG=/etc/contextforge/config.yaml
MCPGATEWAY_PORT=4444
Acceptance Criteria
Related
- Container deployment already handles this via orchestration
- Kubernetes deployment uses native pod lifecycle
- This addresses bare-metal/VM deployment scenarios
Labels
enhancement, devops, deployment
Summary
Implement OS-level service management for ContextForge, enabling it to run as a managed system service with proper lifecycle management (start, stop, restart, enable, disable).
Motivation
Currently, ContextForge must be started manually or via container orchestration. For bare-metal or VM deployments, users need proper OS integration to:
Proposed Implementation
1. Systemd (Linux)
Create a systemd service unit file (
contextforge.service):Type=notifyorType=simplewith proper readiness signaling/etc/contextforge/contextforge.env)2. Launchd (macOS)
Create a launchd plist file (
com.contextforge.gateway.plist):3. Windows Service (Optional)
Consider pywin32 or NSSM wrapper for Windows service support:
4. CLI Commands
Extend
mcpgatewayCLI with service management:5. Installation Scripts
scripts/install-service.shfor Linux/macOSscripts/install-service.ps1for Windows (if supported)make install-service,make uninstall-serviceConfiguration
Service configuration via environment or config file:
Acceptance Criteria
Related
Labels
enhancement, devops, deployment