-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-daemon.sh
More file actions
executable file
·33 lines (25 loc) · 819 Bytes
/
Copy pathrun-daemon.sh
File metadata and controls
executable file
·33 lines (25 loc) · 819 Bytes
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
#!/bin/bash
# Daemon wrapper for unified MCP server
# Keeps stdin open for stdio transport via FIFO
cd "$(dirname "$0")"
FIFO=/tmp/mcp-server-stdin
rm -f "$FIFO"
mkfifo "$FIFO"
ulimit -n 65536
exec >>data/logs/unified.stdout.log 2>>data/logs/unified.stderr.log
echo "[$(date)] Starting unified server..."
# Start Python with FIFO as stdin (opens read end)
# AND open write end in same command to prevent deadlock
(
exec 3>"$FIFO" # Open write end (unblocks read end)
while kill -0 $! 2>/dev/null; do sleep 60; done
) &
KEEPER_PID=$!
.venv/bin/python3 -u src/unified/server/main.py < "$FIFO" &
SERVER_PID=$!
echo "[$(date)] Started unified server PID=$SERVER_PID keeper=$KEEPER_PID"
# Wait for server to exit
wait $SERVER_PID
echo "[$(date)] Server exited with code $?"
exec 3>&- 2>/dev/null
rm -f "$FIFO"