Setup as a Background Service

This article instructs how to set up the Robocorp Workforce Agent Core background process on a Linux machine so that you get a new Unattended Worker into your Control Room.

The primary purpose of running Robocorp Workforce Agent Core as a service is to set up your machine as a constant Environment resource in Control Room just by having the machine powered on.

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 Workers -page. Note that Workforce Agent is always linked to a specific workspace in Control Room to avoid accidental runs between development and production Workers.

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 - Minimal 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

  • Create the service config file

    touch /etc/systemd/system/RobocorpAgentCore.service sudo chmod 664 /etc/systemd/system/RobocorpAgentCore.service
  • 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
  • Setup and start the service:

    sudo systemctl daemon-reload sudo systemctl start RobocorpAgentCore.service sudo systemctl status RobocorpAgentCore.service

Having the service start at boot

If you want the service to be running after startup you have to run:

sudo systemctl enable 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
Last edit: November 22, 2022