-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathstart_worker_multinode.sh
More file actions
executable file
·80 lines (68 loc) · 2.17 KB
/
start_worker_multinode.sh
File metadata and controls
executable file
·80 lines (68 loc) · 2.17 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# KernelGym Multi-Node Worker Startup Wrapper
# For worker-only nodes that connect to a remote KernelGym API/Redis server
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${BLUE}KernelGym Multi-Node Worker Startup${NC}"
echo "==================================================="
# Resolve repo root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="${SCRIPT_DIR}"
cd "$ROOT_DIR"
# Check .env
if [[ ! -f ".env" ]]; then
echo -e "${RED}Error: .env file not found${NC}"
echo ""
echo -e "${YELLOW}This script requires a worker-only .env configuration.${NC}"
echo ""
echo "Create one with at least:"
echo " API_HOST=<main_server_ip>"
echo " API_PORT=<main_server_port>"
echo " REDIS_HOST=<main_server_ip>"
echo " REDIS_PORT=<redis_port>"
echo ""
echo "Optional:"
echo " REDIS_PASSWORD=<password>"
echo " GPU_DEVICES=[0,1] or 0,1"
echo " NODE_ID=<node-name>"
exit 1
fi
# Load .env
set -o allexport
source .env
set +o allexport
# Verify intended usage (NODE_ID recommended)
if [[ -z "${NODE_ID:-}" ]]; then
echo -e "${YELLOW}Warning: NODE_ID not set in .env${NC}"
echo -e "${YELLOW}This script is intended for multi-node deployments.${NC}"
echo -e "${YELLOW}For single-node deployments, use: ${GREEN}./start_all_with_monitor.sh${NC}"
echo ""
read -p "Continue anyway? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
echo ""
echo -e "${BLUE}Configuration:${NC}"
echo -e " Node ID: ${GREEN}${NODE_ID:-<auto>}${NC}"
echo -e " API Server: ${GREEN}${API_HOST}:${API_PORT}${NC}"
echo -e " Redis: ${GREEN}${REDIS_HOST}:${REDIS_PORT}${NC}"
echo -e " GPU Devices: ${GREEN}${GPU_DEVICES:-all}${NC}"
echo ""
# Create server.env symlink for compatibility
if [[ ! -f "server.env" ]]; then
echo -e "${BLUE}Creating server.env symlink to .env...${NC}"
ln -sf .env server.env
echo -e "${GREEN}Created server.env -> .env${NC}"
echo ""
fi
# Start worker-only node
echo -e "${BLUE}Starting worker-only node...${NC}"
echo ""
exec bash start_worker_node.sh