Customizing environment file path
Overview
The Connhex Edge Agent uses an environment file to load configuration variables at startup. By default, this file is located at /opt/connhex/configs/agent.env. This guide explains how to customize the path to this environment file.
Service file location
The Connhex Edge Agent runs as a systemd service. The service configuration file is located at:
/etc/systemd/system/connhex-edge-agent.service
Default environment file path
The default environment file path is:
/opt/connhex/configs/agent.env
This path is specified in the service file using the EnvironmentFile directive.
Customizing the environment file path
To change the location of the environment file, follow these steps:
Step 1: edit the service file
Open the service file with your preferred text editor (requires root privileges):
sudo nano /etc/systemd/system/connhex-edge-agent.service
Or using vi:
sudo vi /etc/systemd/system/connhex-edge-agent.service
Step 2: modify the EnvironmentFile path
Locate the EnvironmentFile line in the [Service] section:
EnvironmentFile=/opt/connhex/configs/agent.env
Change this to your desired path. For example:
EnvironmentFile=/home/myuser/connhex/custom-config.env
Step 3: reload systemd
After editing the service file, reload the systemd daemon to apply the changes:
sudo systemctl daemon-reload
Step 4: restart the service
Restart the Connhex Edge Agent service to use the new environment file path:
sudo systemctl restart connhex-edge-agent.service
Step 5: verify the service
Check that the service started successfully:
sudo systemctl status connhex-edge-agent.service
Important notes
- Ensure the new environment file exists at the specified path before restarting the service
- The user running the service must have read permissions for the environment file
- If using a custom path, make sure it's accessible and won't be accidentally deleted
Troubleshooting
If the service fails to start after changing the environment file path:
Check the service logs:
sudo journalctl -u connhex-edge-agent.service -n 50Verify the file exists and has correct permissions:
ls -la /path/to/your/agent.envEnsure the systemd configuration was reloaded after editing
Double-check the syntax in the service file