Skip to content

Commit 5bdb284

Browse files
committed
addd logging
1 parent 4417996 commit 5bdb284

File tree

1 file changed

+49
-17
lines changed

1 file changed

+49
-17
lines changed

startup.sh

+49-17
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,63 @@
11
#!/bin/bash
22

3+
# Enable error checking and debugging
4+
set -e # Exit on any error
5+
set -x # Print each command before executing
6+
37
# Log startup for debugging
48
echo "Starting initialization script..."
59

6-
# Create parent directories first with error checking
7-
echo "Creating directory structure..."
8-
sudo mkdir -p /mnt/stateful_partition || {
9-
echo "Failed to create stateful_partition directory"
10-
exit 1
11-
}
10+
# Check if directory exists first and show current permissions
11+
echo "Checking current state..."
12+
ls -la /mnt || true
13+
ls -la /mnt/stateful_partition || true
1214

13-
# Create qi-agents directory
14-
sudo mkdir -p /mnt/stateful_partition/qi-agents || {
15-
echo "Failed to create qi-agents directory"
15+
# Try creating base directory first
16+
echo "Creating base directory..."
17+
if ! sudo mkdir -p /mnt/stateful_partition; then
18+
echo "Failed to create /mnt/stateful_partition"
19+
# Try to identify the issue
20+
df -h
21+
mount | grep /mnt
22+
ls -la /mnt
1623
exit 1
17-
}
24+
fi
25+
26+
# Try alternative locations if stateful_partition isn't working
27+
if [ ! -d "/mnt/stateful_partition" ]; then
28+
echo "Using alternative directory /var/lib/qi-agents"
29+
sudo mkdir -p /var/lib/qi-agents || {
30+
echo "Failed to create alternative directory"
31+
exit 1
32+
}
33+
AGENT_DATA_DIR="/var/lib/qi-agents"
34+
else
35+
AGENT_DATA_DIR="/mnt/stateful_partition/qi-agents"
36+
# Create qi-agents directory
37+
sudo mkdir -p "$AGENT_DATA_DIR" || {
38+
echo "Failed to create qi-agents directory"
39+
exit 1
40+
}
41+
fi
1842

1943
# Create data directory
20-
sudo mkdir -p /mnt/stateful_partition/qi-agents/data || {
44+
echo "Creating data directory in $AGENT_DATA_DIR..."
45+
sudo mkdir -p "$AGENT_DATA_DIR/data" || {
2146
echo "Failed to create data directory"
2247
exit 1
2348
}
2449

25-
# Set permissions
50+
# Set permissions with verbose output
2651
echo "Setting directory permissions..."
27-
sudo chmod -R 777 /mnt/stateful_partition/qi-agents || {
52+
sudo chmod -Rv 777 "$AGENT_DATA_DIR" || {
2853
echo "Failed to set permissions"
2954
exit 1
3055
}
3156

32-
# Verify directory structure
57+
# Verify directory structure and permissions
3358
echo "Verifying directory structure..."
34-
ls -la /mnt/stateful_partition/qi-agents/
59+
ls -la "$AGENT_DATA_DIR"
60+
ls -la "$AGENT_DATA_DIR/data"
3561

3662
# Pull latest image with verification
3763
echo "Pulling latest image..."
@@ -52,7 +78,7 @@ echo "Starting container..."
5278
docker run -d \
5379
--name ${FULL_NAME} \
5480
--restart=always \
55-
-v /mnt/stateful_partition/qi-agents/data:/app/agent/data \
81+
-v "$AGENT_DATA_DIR/data":/app/agent/data \
5682
-e AGENTS_BUCKET_NAME="${AGENTS_BUCKET_NAME}" \
5783
-e CHARACTER_FILE="${CHARACTER_FILE}" \
5884
-e SMALL_GOOGLE_MODEL="${SMALL_GOOGLE_MODEL}" \
@@ -70,5 +96,11 @@ if ! docker ps | grep ${FULL_NAME}; then
7096
exit 1
7197
fi
7298

73-
# Log success
99+
# Final verification
100+
echo "Verifying final state..."
101+
df -h
102+
mount
103+
docker ps
104+
ls -la "$AGENT_DATA_DIR"
105+
74106
echo "Startup script completed successfully"

0 commit comments

Comments
 (0)