File size: 1,360 Bytes
1acf3b6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
#!/bin/bash
# Create directories for nginx logs and pid file within $HOME
mkdir -p $HOME/nginx_run $HOME/nginx_logs
# Start Aim UI in the background
echo "Starting Aim UI on port 43800..."
# Run directly as aim_user
aim up --host 0.0.0.0 --port 43800 --repo $HOME &
AIM_UP_PID=$!
# Start Aim Server in the background
echo "Starting Aim Server on port 53800..."
# Run directly as aim_user
aim server --host 0.0.0.0 --port 53800 --repo $HOME &
AIM_SERVER_PID=$!
# Wait a few seconds for services to potentially start
sleep 5
# Check if aim processes are still running
if ! ps -p $AIM_UP_PID > /dev/null; then
echo "Aim UI failed to start." >&2
# exit 1 # Optional: exit if a service fails
fi
if ! ps -p $AIM_SERVER_PID > /dev/null; then
echo "Aim Server failed to start." >&2
# exit 1 # Optional: exit if a service fails
fi
echo "Aim services seem to be starting..."
# Start nginx in the foreground using the system config file
# Run directly as aim_user (no sudo needed)
echo "Starting nginx..."
nginx -c /etc/nginx/nginx.conf -g 'daemon off;'
# If nginx exits, stop the background aim processes
echo "Nginx exited. Stopping Aim services..."
# Use kill without sudo, as processes are owned by aim_user
kill $AIM_UP_PID $AIM_SERVER_PID
# Wait for processes to ensure they are terminated
wait $AIM_UP_PID $AIM_SERVER_PID
echo "Exiting." |