diff --git a/.gitignore b/.gitignore index e729125..646ada1 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,8 @@ *.cypython -nohup.out \ No newline at end of file +nohup.out + +server.log + +server.pid \ No newline at end of file diff --git a/app/__pycache__/main.cpython-312.pyc b/app/__pycache__/main.cpython-312.pyc index 4c7ce62..d42cd7b 100644 Binary files a/app/__pycache__/main.cpython-312.pyc and b/app/__pycache__/main.cpython-312.pyc differ diff --git a/app/routers/__pycache__/investors.cpython-312.pyc b/app/routers/__pycache__/investors.cpython-312.pyc index a2ced80..1209ef6 100644 Binary files a/app/routers/__pycache__/investors.cpython-312.pyc and b/app/routers/__pycache__/investors.cpython-312.pyc differ diff --git a/server_manager.sh b/server_manager.sh new file mode 100755 index 0000000..03fb259 --- /dev/null +++ b/server_manager.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +# Server management script for app/main.py +# Usage: ./server_manager.sh start|stop|restart + +PID_FILE="server.pid" +LOG_FILE="server.log" + +start() { + if [ -f "$PID_FILE" ] && kill -0 $(cat "$PID_FILE") 2>/dev/null; then + echo "Server is already running (PID: $(cat "$PID_FILE"))" + return 1 + fi + echo "Starting server..." + nohup uv run app/main.py > "$LOG_FILE" 2>&1 & + echo $! > "$PID_FILE" + echo "Server started (PID: $(cat "$PID_FILE"))" +} + +stop() { + if [ ! -f "$PID_FILE" ]; then + echo "Server is not running (no PID file found)" + return 1 + fi + PID=$(cat "$PID_FILE") + if ! kill -0 "$PID" 2>/dev/null; then + echo "Server is not running (PID $PID not found)" + rm -f "$PID_FILE" + return 1 + fi + echo "Stopping server (PID: $PID)..." + kill "$PID" + # Wait for process to stop + for i in {1..10}; do + if ! kill -0 "$PID" 2>/dev/null; then + break + fi + sleep 1 + done + if kill -0 "$PID" 2>/dev/null; then + echo "Force killing server..." + kill -9 "$PID" + fi + rm -f "$PID_FILE" + echo "Server stopped" +} + +restart() { + stop + sleep 2 + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac \ No newline at end of file