Skip to content

Systemd Daemon Service Integration#58

Merged
Furisto merged 4 commits into
mainfrom
systemd
Oct 30, 2025
Merged

Systemd Daemon Service Integration#58
Furisto merged 4 commits into
mainfrom
systemd

Conversation

@Furisto
Copy link
Copy Markdown
Owner

@Furisto Furisto commented Oct 30, 2025

Overview

Introduces systemd daemon service support for Linux and macOS with improved installation, configuration, and error handling.

Key Changes

Daemon Service Management

• Support for both user and system daemon services on Linux and macOS
• Refactored systemd unit files (socket and service units) for improved modularity
• Enhanced daemon_install command with better service configuration

System-specific Improvements

• Linux: Updated socket and service unit files with standardized naming
• macOS: Refactored LaunchAgent configuration (http.xml, unix.xml)
• Corrected ExecStart paths and unit path references

CLI & Output

• Silenced command usage output for cleaner error reporting
• Improved error handling in fail/error.go with better context
• Enhanced terminal session messaging

Furisto and others added 4 commits October 29, 2025 14:13
Add --system flag to daemon install command to distinguish between user and
system service installations. This enables running the daemon without root
privileges as a user service, or installing as a privileged system daemon.

Key changes:
• Add --system flag to daemon_install options
• Root privilege enforcement for system service installations on both platforms
• Linux (systemd):
  - User services: ~/.config/systemd/user/ with user socket directory creation
  - System services: /etc/systemd/system/ (requires root)
  - Use --user flag for systemctl commands for user services
  - Socket uses %t specifier for runtime directory (resolves to /run or \$XDG_RUNTIME_DIR)
• macOS (launchd):
  - User services: ~/Library/LaunchAgents with user-specific directories
  - System services: /Library/LaunchDaemons (requires root)
  - Use launchctl bootstrap system vs bootstrap gui/{userID}
  - Log and socket paths respect UserInfo methods (ConstructStateDir, ConstructRuntimeDir)
• Update service templates with dynamic log and socket paths
• Update createOrUpdateContext to use correct socket paths based on service type

User services use standard XDG and macOS directories via UserInfo methods,
while system services use system-level paths. The daemon maintains the same
functionality with proper privilege separation.

Co-authored-by: construct-agent <noreply@construct.sh>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 30, 2025

Walkthrough

The pull request refactors daemon installation and error handling mechanisms. It removes the pipefail option from a shell script, updates error handlers across CLI commands to accept Cobra command context as a parameter, and adds a System boolean option to enable system-wide daemon installation. Service templates for systemd and launchd are modified to use templated variables for socket paths and log directories instead of hardcoded values. The UserInfo interface is refactored to replace ConstructStateDir() with ConstructLogDir() and ConstructRuntimeDir(), which use platform-specific directory paths (Darwin: ~/Library/Logs/construct; others: XDG-based), and adds an IsRoot() method. Service template data structures are extended with LogDir and SockPath fields to support system versus user context differentiation.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 96f475c and d6cc7bb.

📒 Files selected for processing (16)
  • backend/tool/system/command.go (1 hunks)
  • frontend/cli/cmd/agent_list.go (1 hunks)
  • frontend/cli/cmd/daemon_install.go (14 hunks)
  • frontend/cli/cmd/deployment/linux/construct-http.socket (1 hunks)
  • frontend/cli/cmd/deployment/linux/construct-unix.socket (1 hunks)
  • frontend/cli/cmd/deployment/linux/construct.service (1 hunks)
  • frontend/cli/cmd/deployment/macos/http.xml (1 hunks)
  • frontend/cli/cmd/deployment/macos/unix.xml (2 hunks)
  • frontend/cli/cmd/exec.go (1 hunks)
  • frontend/cli/cmd/new.go (1 hunks)
  • frontend/cli/cmd/resume.go (1 hunks)
  • frontend/cli/cmd/root.go (1 hunks)
  • frontend/cli/cmd/update.go (1 hunks)
  • frontend/cli/pkg/fail/error.go (2 hunks)
  • frontend/cli/pkg/terminal/session.go (1 hunks)
  • shared/services.go (2 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@Furisto Furisto merged commit 2c5345e into main Oct 30, 2025
1 of 2 checks passed
@sentry
Copy link
Copy Markdown

sentry Bot commented Nov 5, 2025

Issues attributed to commits in this pull request

This pull request was merged and Sentry observed the following issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant