Closed
Description
customers are looking to send an activity "ping" to workspaces to keep them from auto-shutting off. we have the below API call documented, but this does not update the workspace last_used_at
time (retrieved via /api/v2/users/{user}/workspace/{workspace-name}
):
#!/bin/bash
# Send workspace activity as long as the job is still running
while true
do
if pgrep -f "my_training_script.py" > /dev/null
then
curl -X POST "https://coder.example.com/api/v2/workspaceagents/me/report-stats" \
-H "Coder-Session-Token: $CODER_AGENT_TOKEN" \
-d '{
"connection_count": 1
}'
# Sleep for 30 minutes (1800 seconds) if the job is running
sleep 1800
else
# Sleep for 1 minute (60 seconds) if the job is not running
sleep 60
fi
done