misc: add support for relay systemd install#15
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR introduces systemd service management capabilities for the Infisical relay component, allowing it to be installed, managed, and uninstalled as a proper Linux system service. The changes span three files:
-
Constants Addition (
packages/gateway-v2/constants.go): Two new environment variable name constants (RELAY_HOST_ENV_NAMEandRELAY_TYPE_ENV_NAME) are added to support consistent configuration between command-line and systemd service modes. -
Systemd Management Logic (
packages/relay/systemd.go): A new file implementing the core systemd service installation and uninstallation functionality. It creates systemd unit files with security hardening features (PrivateTmp, resource limits), generates configuration files with authentication credentials, and manages the service lifecycle through systemctl commands. -
Command Interface (
packages/cmd/relay.go): The relay command is enhanced with two new subcommands (installanduninstall) for systemd service management. The existingstartcommand is modified to use environment variables as fallbacks, enabling it to work both interactively and as a systemd service.
The implementation supports both 'org' and 'instance' relay types with different authentication mechanisms - org-type relays use INFISICAL_TOKEN while instance-type relays use INFISICAL_RELAY_AUTH_SECRET. The systemd service template includes proper security configurations and integrates with existing Infisical infrastructure patterns. This change enables production-ready deployment of relay services with standard Linux service management capabilities like automatic startup, proper logging, and service lifecycle management through systemctl.
Confidence score: 3/5
- This PR introduces significant security-sensitive functionality that requires careful review due to credential handling and systemd service creation
- Score reflects concerns about sensitive data being written to disk, potential command injection vectors, and the need for root privileges
- Pay close attention to
packages/relay/systemd.gofor credential handling and file permission validation
Context used:
Context - For better readability, consider splitting complex expressions into multiple variables. (link)
3 files reviewed, 1 comment
Description 📣
This PR adds support for installing and uninstalling relay as a systemd service
Type ✨
Tests 🛠️
# Here's some code block to paste some code snippets