-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-mesh.sh
More file actions
executable file
·56 lines (48 loc) · 2.07 KB
/
Copy pathstart-mesh.sh
File metadata and controls
executable file
·56 lines (48 loc) · 2.07 KB
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
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# NEURAL_MESH Memory Service — Production Startup
# Usage: ./start-mesh.sh [--dev]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# ─── Load env ────────────────────────────────────────────────
if [ -f ".env" ]; then
set -a
source .env
set +a
echo "[mesh] loaded .env"
else
echo "[mesh] WARNING: no .env found — using defaults (no auth!)"
fi
# ─── Defaults ────────────────────────────────────────────────
PORT="${NEURAL_MESH_PORT:-4021}"
HOST="${NEURAL_MESH_HOST:-127.0.0.1}"
WORKERS="${NEURAL_MESH_WORKERS:-2}"
TIMEOUT="${NEURAL_MESH_TIMEOUT:-120}"
# ─── Ensure runtime dir exists ───────────────────────────────
mkdir -p "${NEURAL_MESH_SAFE_IO_DIR:-./runtime}"
mkdir -p "${NEURAL_MESH_SAFE_IO_DIR:-./runtime}/exports"
# ─── Sanity check ────────────────────────────────────────────
if [ ! -f "server.py" ]; then
echo "[mesh] FATAL: server.py not found in $SCRIPT_DIR"
exit 1
fi
if [ ! -d ".venv-server" ]; then
echo "[mesh] creating venv..."
python3 -m venv .venv-server
.venv-server/bin/pip install flask gunicorn 2>&1 | tail -2
fi
# ─── Start ───────────────────────────────────────────────────
if [ "${1:-}" = "--dev" ]; then
echo "[mesh] DEV MODE — Flask dev server on $HOST:$PORT"
exec .venv-server/bin/python server.py
else
echo "[mesh] PRODUCTION — gunicorn ($WORKERS workers) on $HOST:$PORT"
exec .venv-server/bin/gunicorn \
--bind "$HOST:$PORT" \
--workers "$WORKERS" \
--timeout "$TIMEOUT" \
--access-logfile - \
--error-logfile - \
--log-level info \
server:app
fi