Created
May 11, 2026 09:12
-
-
Save koliadych/e31276fa56b0502ac73bbb23a6b8bbf0 to your computer and use it in GitHub Desktop.
fintechner restart + watch backfill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| CMD_ID=$(aws --region "$REGION" ssm send-command \ | |
| --instance-ids "$INSTANCE_ID" \ | |
| --document-name AWS-RunShellScript \ | |
| --parameters '{"commands":["echo === restart connector ===","sudo systemctl restart fintechner-connector","sleep 10","echo === backfill log lines ===","sudo journalctl -u fintechner-connector --since \"30 sec ago\" --no-pager | grep -iE \"closedtrades|backfill|closed trade|fatal|ERROR\" | head -30","echo === closed_trades count after restart ===","sudo docker exec timescale psql -U fintechner -d fintechner -tA -c \"SELECT COUNT(*) FROM closed_trades;\""]}' \ | |
| --query Command.CommandId --output text) | |
| for i in $(seq 1 20); do | |
| sleep 3 | |
| STATUS=$(aws --region "$REGION" ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query Status --output text 2>/dev/null || echo Pending) | |
| case "$STATUS" in Success|Failed|Cancelled|TimedOut) break ;; esac | |
| done | |
| aws --region "$REGION" ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query StandardOutputContent --output text | |
| echo "--- STDERR ---" | |
| aws --region "$REGION" ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query StandardErrorContent --output text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment