Python functions as REST objects, with clustering, load balancing and state replication; no containers or orchestration.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-primitive.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-primitive.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-primitive.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Dan Q Consolidate duplicate QUICKSTARTs on the top-level file 503f830 7 months ago History
server.sh · 1.8 KB · 76 lines
1#!/bin/bash
2# Server management script with PID file support
3
4PID_FILE=".server.pid"
5LOG_FILE="server.log"
6
7case "$1" in
8 start)
9 if [ -f "$PID_FILE" ]; then
10 PID=$(cat "$PID_FILE")
11 if ps -p "$PID" > /dev/null 2>&1; then
12 echo "Server is already running (PID: $PID)"
13 exit 1
14 else
15 echo "Removing stale PID file"
16 rm "$PID_FILE"
17 fi
18 fi
19
20 echo "Starting server..."
21 .venv/bin/python run_server.py > "$LOG_FILE" 2>&1 &
22 echo $! > "$PID_FILE"
23 echo "Server started (PID: $(cat $PID_FILE))"
24 echo "Logs: tail -f $LOG_FILE"
25 ;;
26
27 stop)
28 if [ ! -f "$PID_FILE" ]; then
29 echo "PID file not found. Server not running?"
30 exit 1
31 fi
32
33 PID=$(cat "$PID_FILE")
34 if ps -p "$PID" > /dev/null 2>&1; then
35 echo "Stopping server (PID: $PID)..."
36 kill "$PID"
37 rm "$PID_FILE"
38 echo "Server stopped"
39 else
40 echo "Server not running (stale PID file)"
41 rm "$PID_FILE"
42 fi
43 ;;
44
45 restart)
46 $0 stop
47 sleep 2
48 $0 start
49 ;;
50
51 status)
52 if [ -f "$PID_FILE" ]; then
53 PID=$(cat "$PID_FILE")
54 if ps -p "$PID" > /dev/null 2>&1; then
55 echo "Server is running (PID: $PID)"
56 else
57 echo "Server is not running (stale PID file)"
58 fi
59 else
60 echo "Server is not running"
61 fi
62 ;;
63
64 logs)
65 if [ -f "$LOG_FILE" ]; then
66 tail -f "$LOG_FILE"
67 else
68 echo "Log file not found"
69 fi
70 ;;
71
72 *)
73 echo "Usage: $0 {start|stop|restart|status|logs}"
74 exit 1
75 ;;
76esac