# Stop On-prem Agent

An on-prem agent process is typically stopped through a SIGTERM. To handle this termination gracefully, you should use the shutdown script (./bin/shutdown.sh) that comes with the on-prem agent. This helps to terminate a running on-prem agent safely without disrupting any pending requests.

WHO CAN USE THIS FEATURE?

Graceful shutdown script is available for on-prem agent version 2.10.0 or later.

# Why is this important?

On-prem agent processes requests that may take a long time to process. For example, a complex query that can take minutes to get a response from the database. When terminating an agent, you want to make sure that these requests are completed to avoid recipe job failures or data loss. Using the shutdown script ensures that the agent is no longer processing any pending requests before proceeding with the termination.

# How does it work?

1

We recommend disabling the on-prem agent first, to prevent any further actions to be routed to this OPA. This can be done through the on-prem page or Developer API. To prevent disruption to your recipes, ensure that there is an active backup on-prem agent in the group.

2

Initiate a graceful shutdown by executing the shutdown script.

./shutdown.sh
3

The script begins by rejecting any new requests to the agent.

4

Next, it checks the status of the agent to determine whether there are any pending requests. If a pending request is found, the script will pause and check again, following a poll schedule.

This step is repeated until 2 conditions are met:

  • No more pending requests
  • Total time exceeds the timeout
5

If there are no more pending requests, the script will send SIGTERM to gracefully terminate the agent process.

6

Alternatively, if the script has waited longer than the timeout, a SIGKILL will be sent to forcibly terminate the agent process.

# Usage options

./shutdown.sh [args…]

# Examples

./shutdown.sh
./shutdown.sh --port=3000 --timeout=600
./shutdown.sh --help

# Optional arguments

Argument Description
--port TCP port of running Workato Agent

Default: 3000
--timeout Graceful shutdown timeout (in seconds). When this is exceeded, the script will send SIGKILL to forcibly terminate the agent.

Default: 600
--help Display help list of all arguments, similar to this table.