# 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?
Initiate a graceful shutdown by executing the shutdown script.
The script begins by rejecting any new requests to the agent.
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
If there are no more pending requests, the script will send
SIGTERM to gracefully terminate the agent process.
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 ./shutdown.sh --port=3000 --timeout=600 ./shutdown.sh --help
# Optional arguments
|--port||TCP port of running Workato Agent|
|--timeout||Graceful shutdown timeout (in seconds). When this is exceeded, the script will send SIGKILL to forcibly terminate the agent.|
|--help||Display help list of all arguments, similar to this table.|