Linux Service setup for Workforce Agent Core

Prerequisites

  • You should be familiar with Systemctl Utility in Linux, systemd and command line use of Linux.
  • The target machine must have at least curl or similar to download needed files and a text-editor of your choosing.
  • To follow along, you need a Robocorp account to access Control Room and Robocorp Workforce Agent Core.
  • If you haven't already, you might want first to follow the Quickstart guide to get familiar with Control Room.
  • You must have sudo permissions on the machine to set up the service.

Limitations

On Linux, you will not get UI access via this service setup; it is limited to so-called "headless" runs that do not need UI-level actions. It is good to note that a lot can be done even at this level; browser automation, excel data handling, etc., do NOT require any UI.

Officially we are testing the setups on Ubuntu distros; as there are so many different Linux distros, the guides here cannot cover all, but the setup is quite simple and should be adaptable in most cases.

The guide below does not cover the installation of other components your robot might need, e.g., chromium-browser

Setup and test Workforce Agent Core

Replace <link token> below with a link token created from the Control Room environments page. Note that Workforce Agent is always linked to a specific workspace in Control Room to avoid accidental runs between development and production environments.

mkdir ~/.robocorp
curl https://downloads.robocorp.com/workforce-agent-core/releases/latest/linux64/robocorp-workforce-agent-core -o ~/.robocorp/robocorp-workforce-agent-core
chmod +x ~/.robocorp/robocorp-workforce-agent-core
~/.robocorp/robocorp-workforce-agent-core -v
~/.robocorp/robocorp-workforce-agent-core link <link token>
~/.robocorp/robocorp-workforce-agent-core start --service

At this point, you should be able to see the Environment in the Idle state in Control Room, and you can test executing a simple bot like Python template.

This setup, however, will shut down once you log out of the machine or the terminal, so you should move on to the service setup next.

Setup service

  1. Create the service config file
    touch /etc/systemd/system/RobocorpAgentCore.service
    sudo chmod 664 /etc/systemd/system/RobocorpAgentCore.service
    
  2. Add the following content to the config file
    • Edit the file /etc/systemd/system/RobocorpAgentCore.service with your favorite text editor.
      [Unit]
      Description=Robocorp Agent
      
      [Service]
      User=<user>
      ExecStart=/home/centos/.robocorp/robocorp-workforce-agent-core start --service
      Restart=always
      PrivateDevices=true
      ProtectControlGroups=true
      ProtectKernelTunables=true
      ProtectSystem=full
      RestrictSUIDSGID=true
      PrivateTmp=yes
      
      [Install]
      WantedBy=default.target
      
      • Replace <user> with actual user
      • The ExecStart needs to have the absolute path
  3. Setup and start the service:
    sudo systemctl daemon-reload
    sudo systemctl start RobocorpAgentCore.service
    sudo systemctl status RobocorpAgentCore.service
    

Maintain the service

The typical maintenance task is to update the Agent Core executable.

For that, you need to:

  • Stop the service
  • Download the latest Agent Core
  • Restart the service
sudo systemctl stop RobocorpAgentCore.service
curl https://downloads.robocorp.com/workforce-agent-core/releases/latest/linux64/robocorp-workforce-agent-core -o ~/.robocorp/robocorp-workforce-agent-core
sudo systemctl start RobocorpAgentCore.service
sudo systemctl status RobocorpAgentCore.service
August 11, 2022