WIP! A BB-style forum, on the ATmosphere!
We're still working... we'll be back soon when we have something to show off!
node
typescript
hono
htmx
atproto
1#!/bin/sh
2set -e # Exit on error
3
4echo "=== atBB Container Starting ==="
5
6# Start nginx
7echo "Starting nginx..."
8nginx
9sleep 1
10
11# Read nginx PID from PID file
12if [ ! -f /tmp/nginx.pid ]; then
13 echo "ERROR: nginx failed to start (no PID file)"
14 exit 1
15fi
16NGINX_PID=$(cat /tmp/nginx.pid)
17
18# Verify nginx is running
19if ! kill -0 $NGINX_PID 2>/dev/null; then
20 echo "ERROR: nginx failed to start (process not running)"
21 exit 1
22fi
23echo "nginx started (PID: $NGINX_PID)"
24
25# Start appview (background)
26echo "Starting appview..."
27cd /app/apps/appview
28NODE_ENV=production node dist/index.js &
29APPVIEW_PID=$!
30sleep 2
31
32# Verify appview started
33if ! kill -0 $APPVIEW_PID 2>/dev/null; then
34 echo "ERROR: appview failed to start"
35 kill $NGINX_PID 2>/dev/null || true
36 exit 1
37fi
38echo "appview started (PID: $APPVIEW_PID)"
39
40# Start web (background)
41echo "Starting web..."
42cd /app/apps/web
43NODE_ENV=production node dist/index.js &
44WEB_PID=$!
45sleep 2
46
47# Verify web started
48if ! kill -0 $WEB_PID 2>/dev/null; then
49 echo "ERROR: web failed to start"
50 kill $NGINX_PID $APPVIEW_PID 2>/dev/null || true
51 exit 1
52fi
53echo "web started (PID: $WEB_PID)"
54echo "=== All services started, container ready ==="
55
56# Cleanup function for graceful shutdown
57cleanup() {
58 echo "Received shutdown signal, stopping services..."
59 kill $NGINX_PID $APPVIEW_PID $WEB_PID 2>/dev/null || true
60 wait $NGINX_PID $APPVIEW_PID $WEB_PID 2>/dev/null || true
61 exit 0
62}
63
64# Setup signal handling
65trap cleanup TERM INT
66
67# Monitor processes - exit if any critical service crashes
68while true; do
69 if ! kill -0 $NGINX_PID 2>/dev/null; then
70 echo "ERROR: nginx crashed, shutting down container"
71 cleanup
72 fi
73 if ! kill -0 $APPVIEW_PID 2>/dev/null; then
74 echo "ERROR: appview crashed, shutting down container"
75 cleanup
76 fi
77 if ! kill -0 $WEB_PID 2>/dev/null; then
78 echo "ERROR: web crashed, shutting down container"
79 cleanup
80 fi
81 sleep 5
82done