PowerConnect for SAP Solutions
Breadcrumbs

Using Systemd to manage the PowerConnect Cloud Agent

The PowerConnect Cloud agent can be managed by Systemd.

  1. Create the powerconnect systemd service file:

sudo vi /etc/systemd/system/powerconnect.service

  1. Populate the contents as follows:

[Unit]
Description=PowerConnect Cloud agent

[Service]
Environment=POWERCONNECT_SECRET=<insert secret here>
# Environment=POWERCONNECT_MEMBERS=<insert members here>
SuccessExitStatus=143

User=powerconnect
Group=powerconnect

Type=forking

Restart=on-failure
RestartSec=30

ExecStart=/bin/bash /opt/powerconnect/bin/powerconnect.sh start
ExecStop=/bin/bash /opt/powerconnect/bin/powerconnect.sh stop

[Install]
WantedBy=multi-user.target
  1. Set the POWERCONNECT_SECRET variable placeholder with a value as shown above

  2. Alternatively to avoid including the POWERCONNECT_SECRET directly in the systemd service file you can create an environment file containing the secret which is only readable by the powerconnect user

    1. touch /home/powerconnect/pcenv

    2. Populate the environment file with the secret
      POWERCONNECT_SECRET=<insert secret>

    3. Refer to the environment file in the systemd config

      [Unit]
      Description=PowerConnect Cloud agent
      
      [Service]
      EnvironmentFile=<insert env file location here> e.g. /home/powerconnect/pcenv
      # Environment=POWERCONNECT_MEMBERS=<insert members here>
      SuccessExitStatus=143
      
      User=powerconnect
      Group=powerconnect
      
      Type=forking
      
      Restart=on-failure
      RestartSec=30
      
      ExecStart=/bin/bash /opt/powerconnect/bin/powerconnect.sh start
      ExecStop=/bin/bash /opt/powerconnect/bin/powerconnect.sh stop
      
      [Install]
      WantedBy=multi-user.target
      
  3. Uncomment and set the POWERCONNECT_MEMBERS variable if running a cluster

  4. Reload the Systemd service:

sudo systemctl daemon-reload

  1. Start the PowerConnect Cloud agent using Systemd:

sudo systemctl start powerconnect.service

  1. Check the status:

systemctl status powerconnect

  1. To have Systemd start the PowerConnect Cloud agent when the host starts up:

sudo systemctl enable powerconnect