How Can I Use systemd to Manage the Hybrid Deployment Agent?
Question
How can I use systemd to manage the Hybrid Deployment Agent?
Environment
Container platform: Docker and Podman
Answer
You can configure systemd to manage the Hybrid Deployment Agent and start it automatically when the host boots.
These instructions assume a rootless Docker or Podman installation. The systemd service runs as the specified user, not as the root user.
Stop the Hybrid Deployment Agent. Depending on the container runtime, run one of the following commands:
Docker
./hdagent.sh [-r docker] stopPodman
./hdagent.sh [-r podman] stop
Create the folder path and open the user
systemdunit file for editing:mkdir -p ~/.config/systemd/user/ vi ~/.config/systemd/user/hdagent.serviceAdd the appropriate configuration to the
hdagent.servicefile.Docker
[Unit] Description=Fivetran Hybrid Deployment Agent After=network.target docker.service Requires=default.target [Service] Type=oneshot RemainAfterExit=true WorkingDirectory=%h/fivetran ExecStart=/bin/bash %h/fivetran/hdagent.sh start ExecStop=/bin/bash %h/fivetran/hdagent.sh stop ExecStop=%h/fivetran/hdagent.sh stop Environment=PATH=/usr/bin:/bin [Install] WantedBy=default.targetPodman
[Unit] Description=Fivetran Hybrid Deployment Agent After=network.target podman.service Requires=default.target [Service] Type=oneshot RemainAfterExit=true WorkingDirectory=%h/fivetran ExecStart=/bin/bash %h/fivetran/hdagent.sh start ExecStop=/bin/bash %h/fivetran/hdagent.sh stop Environment=PATH=/usr/bin:/bin [Install] WantedBy=default.target
Reload and enable the service:
export XDG_RUNTIME_DIR=/run/user/$(id -u) systemctl --user daemon-reload systemctl --user enable hdagent.service systemctl --user start hdagent.service systemctl --user status hdagent.serviceVerify that the agent is running:
- Docker
docker ps -a docker logs <container_name_or_id>- Podman
podman ps -a podman logs <container_name_or_id>Enable user lingering so that the user
systemdinstance starts automatically after the host boots. Replace $USERwith the Unix user that runs the agent.sudo loginctl enable-linger $USERVerify that user lingering is enabled:
loginctl show-user $USERConfirm that the
Lingerproperty is set toyes.