Skip to content

Commit 7c30a41

Browse files
committed
revert start-local.sh by removing unused functions and streamlining steps for clarity
1 parent c177074 commit 7c30a41

1 file changed

Lines changed: 5 additions & 72 deletions

File tree

docker/scripts/start-local.sh

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,6 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
77
ENV_FILE="$SCRIPT_DIR/../.env"
88
readonly SEPARATOR="======================================"
99

10-
is_port_in_use() {
11-
local port="$1"
12-
ss -ltn 2>/dev/null | awk 'NR>1 {print $4}' | grep -Eq ":${port}$"
13-
}
14-
15-
is_fwsdb_mapped_to_port() {
16-
local port="$1"
17-
docker ps --format '{{.Names}}\t{{.Ports}}' 2>/dev/null | grep -Eq "fwsdb.*:${port}->5432/tcp"
18-
}
19-
20-
resolve_fws_db_host_port() {
21-
if [[ -n "${FWS_DB_HOST_PORT:-}" ]]; then
22-
echo "Using explicit FWS_DB_HOST_PORT=${FWS_DB_HOST_PORT}"
23-
return
24-
fi
25-
26-
if is_port_in_use 5432; then
27-
if is_fwsdb_mapped_to_port 5432; then
28-
export FWS_DB_HOST_PORT=5432
29-
echo "Detected running fwsdb already mapped to 5432; continuing with FWS_DB_HOST_PORT=5432"
30-
else
31-
export FWS_DB_HOST_PORT=5433
32-
echo "Warning: Host port 5432 is already in use. Falling back to FWS_DB_HOST_PORT=5433"
33-
fi
34-
else
35-
export FWS_DB_HOST_PORT=5432
36-
fi
37-
}
38-
39-
ensure_localstack_local_stage() {
40-
local api_id
41-
local stage_name
42-
43-
api_id=$(docker exec localstack-main awslocal apigateway get-rest-apis --query "items[?name=='FWS API Gateway']|[-1].id" --output text 2>/dev/null | tr -d '\r')
44-
45-
if [[ -z "$api_id" || "$api_id" == "None" ]]; then
46-
echo "Error: Could not find FWS API Gateway in LocalStack" >&2
47-
exit 1
48-
fi
49-
50-
stage_name=$(docker exec localstack-main awslocal apigateway get-stages --rest-api-id "$api_id" --query "item[?stageName=='local'].stageName" --output text 2>/dev/null | tr -d '\r')
51-
52-
if [[ "$stage_name" == "local" ]]; then
53-
echo "✓ LocalStack API stage 'local' is present (API ID: $api_id)"
54-
return
55-
fi
56-
57-
echo "LocalStack API stage 'local' is missing for API ID: $api_id; creating deployment..."
58-
docker exec localstack-main awslocal apigateway create-deployment --rest-api-id "$api_id" --stage-name local >/dev/null
59-
echo "✓ LocalStack API stage 'local' created (API ID: $api_id)"
60-
}
61-
6210
echo "$SEPARATOR"
6311
echo "FWS App Local Startup Script"
6412
echo "$SEPARATOR"
@@ -127,15 +75,6 @@ fi
12775
echo "✓ All required environment variables are set"
12876
echo ""
12977

130-
# Step 1.5: Resolve DB host port and disable AWS pager
131-
echo "Step 1.5: Resolving DB host port..."
132-
resolve_fws_db_host_port
133-
export FWS_DB_HOST_PORT
134-
export AWS_PAGER=""
135-
136-
echo "✓ Using FWS_DB_HOST_PORT=$FWS_DB_HOST_PORT"
137-
echo ""
138-
13978
# Step 2: Bootstrap LocalStack API
14079
echo "Step 2: Bootstrapping LocalStack API..."
14180
FWS_API_DIR="$PROJECT_ROOT/../fws-api"
@@ -153,29 +92,23 @@ npm run bootstrap-debug
15392
echo "✓ LocalStack API bootstrapped successfully"
15493
echo ""
15594

156-
# Step 3: Ensure LocalStack API stage exists
157-
echo "Step 3: Verifying LocalStack API stage..."
158-
ensure_localstack_local_stage
159-
160-
echo ""
161-
162-
# Step 4: Update LocalStack URL in .env
163-
echo "Step 4: Updating FWS_API_URL in .env..."
95+
# Step 3: Update LocalStack URL in .env
96+
echo "Step 3: Updating FWS_API_URL in .env..."
16497
cd "$SCRIPT_DIR"
16598
./update-localstack-url.sh
16699

167100
echo "✓ FWS_API_URL updated"
168101
echo ""
169102

170-
# Step 5: Start Docker Compose services
171-
echo "Step 5: Starting Docker Compose services..."
103+
# Step 4: Start Docker Compose services
104+
echo "Step 4: Starting Docker Compose services..."
172105
cd "$PROJECT_ROOT"
173106
docker compose -f docker/infrastructure.yml -f docker/app.yml up -d --build
174107

175108
echo "✓ Services started successfully"
176109
echo ""
177110

178-
# Step 6: Display success message
111+
# Step 5: Display success message
179112
echo "$SEPARATOR"
180113
echo "✓ FWS App is now running!"
181114
echo "$SEPARATOR"

0 commit comments

Comments
 (0)