Moved auth system from nostr_core_lib back into ginxsom. Still debugging but so many changes I wanted to commit.
This commit is contained in:
@@ -3,6 +3,22 @@
|
||||
# Combines nginx and FastCGI restart operations for debugging
|
||||
|
||||
# Configuration
|
||||
|
||||
# Check for --follow flag
|
||||
if [[ "$1" == "--follow" ]]; then
|
||||
echo "=== Following logs in real-time ==="
|
||||
echo "Monitoring: nginx error, nginx access, app stderr, app stdout"
|
||||
echo "Press Ctrl+C to stop following logs"
|
||||
echo
|
||||
|
||||
# Start tailing multiple log files
|
||||
mkdir -p logs/nginx logs/app
|
||||
touch logs/nginx/error.log logs/nginx/access.log logs/app/stderr.log logs/app/stdout.log
|
||||
|
||||
tail -f logs/nginx/error.log logs/nginx/access.log logs/app/stderr.log logs/app/stdout.log &
|
||||
wait
|
||||
exit 0
|
||||
fi
|
||||
FCGI_BINARY="./build/ginxsom-fcgi"
|
||||
SOCKET_PATH="/tmp/ginxsom-fcgi.sock"
|
||||
PID_FILE="/tmp/ginxsom-fcgi.pid"
|
||||
@@ -14,6 +30,13 @@ GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Ensure log directories exist with proper permissions
|
||||
echo "Creating log directories..."
|
||||
mkdir -p logs/nginx logs/app
|
||||
touch logs/app/stderr.log logs/app/stdout.log logs/nginx/error.log logs/nginx/access.log
|
||||
chmod 644 logs/app/stderr.log logs/app/stdout.log logs/nginx/error.log logs/nginx/access.log
|
||||
chmod 755 logs/nginx logs/app
|
||||
|
||||
echo -e "${YELLOW}=== Ginxsom Development Environment Restart ===${NC}"
|
||||
echo "Starting full restart sequence..."
|
||||
|
||||
@@ -43,16 +66,28 @@ wait_for_stop() {
|
||||
|
||||
# Step 1: Stop nginx
|
||||
echo -e "\n${YELLOW}1. Stopping nginx...${NC}"
|
||||
|
||||
# First try to stop nginx gracefully using our config
|
||||
if pgrep -f "nginx.*${NGINX_CONFIG}" > /dev/null; then
|
||||
echo "Found running nginx processes, stopping..."
|
||||
echo "Found nginx processes with our config, stopping gracefully..."
|
||||
nginx -p . -c "${NGINX_CONFIG}" -s stop 2>/dev/null
|
||||
sleep 2
|
||||
fi
|
||||
|
||||
# Kill any remaining nginx processes (including those on port 9001)
|
||||
NGINX_PIDS=$(pgrep nginx)
|
||||
if [ ! -z "$NGINX_PIDS" ]; then
|
||||
echo "Found running nginx processes, stopping..."
|
||||
echo "Nginx PIDs: $NGINX_PIDS"
|
||||
# Try graceful stop first
|
||||
sudo nginx -s stop 2>/dev/null || true
|
||||
sleep 2
|
||||
|
||||
# Force kill any remaining nginx processes
|
||||
NGINX_PIDS=$(pgrep -f "nginx.*${NGINX_CONFIG}")
|
||||
NGINX_PIDS=$(pgrep nginx)
|
||||
if [ ! -z "$NGINX_PIDS" ]; then
|
||||
echo "Force killing remaining nginx processes: $NGINX_PIDS"
|
||||
kill -9 $NGINX_PIDS 2>/dev/null
|
||||
sudo kill -9 $NGINX_PIDS 2>/dev/null || true
|
||||
fi
|
||||
echo -e "${GREEN}nginx stopped${NC}"
|
||||
else
|
||||
@@ -103,30 +138,15 @@ fi
|
||||
|
||||
echo -e "${GREEN}FastCGI cleanup complete${NC}"
|
||||
|
||||
# Step 3: Check if binary exists and is up to date
|
||||
echo -e "\n${YELLOW}3. Checking FastCGI binary...${NC}"
|
||||
if [ ! -f "$FCGI_BINARY" ]; then
|
||||
echo -e "${RED}Error: FastCGI binary not found at $FCGI_BINARY${NC}"
|
||||
echo "Building application..."
|
||||
make
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Build failed! Cannot continue.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "FastCGI binary found: $FCGI_BINARY"
|
||||
|
||||
# Check if source is newer than binary
|
||||
if [ "src/main.c" -nt "$FCGI_BINARY" ] || [ "Makefile" -nt "$FCGI_BINARY" ]; then
|
||||
echo "Source files are newer than binary, rebuilding..."
|
||||
make
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Build failed! Cannot continue.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN}Rebuild complete${NC}"
|
||||
fi
|
||||
# Step 3: Always rebuild FastCGI binary with clean build
|
||||
echo -e "\n${YELLOW}3. Rebuilding FastCGI binary (clean build)...${NC}"
|
||||
echo "Performing clean rebuild to ensure all changes are compiled..."
|
||||
make clean && make
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Build failed! Cannot continue.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN}Clean rebuild complete${NC}"
|
||||
|
||||
# Step 4: Start FastCGI
|
||||
echo -e "\n${YELLOW}4. Starting FastCGI application...${NC}"
|
||||
@@ -141,10 +161,14 @@ if ! command -v spawn-fcgi &> /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start FastCGI application with stderr logging (no wrapper needed)
|
||||
# Create stderr log with timestamp
|
||||
echo "FastCGI starting at $(date)" > logs/fcgi-stderr.log
|
||||
spawn-fcgi -s "$SOCKET_PATH" -M 666 -u "$USER" -g "$USER" -f "$FCGI_BINARY" -P "$PID_FILE" 2>>logs/fcgi-stderr.log
|
||||
# Start FastCGI application with proper logging (daemonized but with redirected streams)
|
||||
# Set debug environment variable for pubkey extraction diagnostics
|
||||
echo "Setting GINX_DEBUG environment for pubkey extraction diagnostics"
|
||||
export GINX_DEBUG=1
|
||||
|
||||
# Start FastCGI application with proper logging (daemonized but with redirected streams)
|
||||
echo "FastCGI starting at $(date)" >> logs/app/stderr.log
|
||||
spawn-fcgi -s "$SOCKET_PATH" -M 666 -u "$USER" -g "$USER" -f "$FCGI_BINARY" -P "$PID_FILE" 1>>logs/app/stdout.log 2>>logs/app/stderr.log
|
||||
|
||||
if [ $? -eq 0 ] && [ -f "$PID_FILE" ]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
|
||||
Reference in New Issue
Block a user