Skip to content

Commit 65aa2c1

Browse files
committed
feat: add health monitor script and service file
1 parent 8897568 commit 65aa2c1

File tree

5 files changed

+132
-83
lines changed

5 files changed

+132
-83
lines changed

docker-compose.prod.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ services:
5353
container_name: neverland-indexer
5454
restart: unless-stopped
5555
working_dir: /app
56-
user: "${UID:-1000}:${GID:-1000}"
5756
environment:
5857
- NODE_ENV=production
5958
- ENVIO_API_TOKEN=${ENVIO_API_TOKEN}

health-monitor.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
# Health monitoring script - run via cron every 5 minutes
3+
4+
HEALTH_ENDPOINT="http://localhost:8080/v1/graphql"
5+
ADMIN_SECRET="H9bN8Q9waXiS"
6+
LOG_FILE="/var/log/neverland-health.log"
7+
COMPOSE_FILE="/home/catalyst/Documents/neverland/neverland-hyperindex/docker-compose.prod.yml"
8+
9+
# Test GraphQL endpoint
10+
response=$(curl -s -o /dev/null -w "%{http_code}" \
11+
-X POST "$HEALTH_ENDPOINT" \
12+
-H "x-hasura-admin-secret: $ADMIN_SECRET" \
13+
-H "Content-Type: application/json" \
14+
-d '{"query": "{ __typename }"}' \
15+
--max-time 10)
16+
17+
if [ "$response" != "200" ]; then
18+
echo "[$(date)] ALERT: GraphQL endpoint returned $response - attempting restart" >> "$LOG_FILE"
19+
20+
# Check which containers are down
21+
cd /home/catalyst/Documents/neverland/neverland-hyperindex
22+
down_containers=$(docker-compose -f "$COMPOSE_FILE" ps | grep -E "Exit|Restarting" || true)
23+
24+
if [ ! -z "$down_containers" ]; then
25+
echo "[$(date)] Down containers: $down_containers" >> "$LOG_FILE"
26+
docker-compose -f "$COMPOSE_FILE" up -d
27+
echo "[$(date)] Restart command executed" >> "$LOG_FILE"
28+
else
29+
echo "[$(date)] All containers running but endpoint unresponsive" >> "$LOG_FILE"
30+
fi
31+
else
32+
# Optionally log success (commented out to avoid log spam)
33+
# echo "[$(date)] OK: Health check passed" >> "$LOG_FILE"
34+
:
35+
fi

neverland-indexer.service

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[Unit]
2+
Description=Neverland HyperIndex
3+
Requires=docker.service
4+
After=docker.service
5+
6+
[Service]
7+
Type=oneshot
8+
RemainAfterExit=yes
9+
WorkingDirectory=/home/catalyst/Documents/neverland/neverland-hyperindex
10+
ExecStart=/usr/bin/docker-compose -f docker-compose.prod.yml up -d
11+
ExecStop=/usr/bin/docker-compose -f docker-compose.prod.yml down
12+
TimeoutStartSec=0
13+
14+
[Install]
15+
WantedBy=multi-user.target

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@
6464
"license": "BUSL-1.1",
6565
"dependencies": {
6666
"envio": "^2.32.3",
67-
"viem": "^2.43.3"
67+
"viem": "^2.43.5"
6868
},
6969
"devDependencies": {
7070
"@types/node": "^25.0.3",
71-
"@typescript-eslint/eslint-plugin": "^8.50.1",
72-
"@typescript-eslint/parser": "^8.50.1",
71+
"@typescript-eslint/eslint-plugin": "^8.51.0",
72+
"@typescript-eslint/parser": "^8.51.0",
7373
"c8": "^10.1.3",
7474
"eslint": "^9.39.2",
7575
"husky": "^9.1.7",

0 commit comments

Comments
 (0)