Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dashboard/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
OCLAW_HOME = pathlib.Path.home() / '.openclaw'
MAX_REQUEST_BODY = 1 * 1024 * 1024 # 1 MB
ALLOWED_ORIGIN = None # Set via --cors; None means restrict to localhost
_DASHBOARD_PORT = 7891 # Updated at startup from --port arg
_DEFAULT_ORIGINS = {
'http://127.0.0.1:7891', 'http://localhost:7891',
'http://127.0.0.1:5173', 'http://localhost:5173', # Vite dev server
Expand Down Expand Up @@ -71,7 +72,7 @@ def cors_headers(h):
elif req_origin in _DEFAULT_ORIGINS:
origin = req_origin
else:
origin = 'http://127.0.0.1:7891'
origin = f'http://127.0.0.1:{_DASHBOARD_PORT}'
h.send_header('Access-Control-Allow-Origin', origin)
h.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
h.send_header('Access-Control-Allow-Headers', 'Content-Type')
Expand Down Expand Up @@ -2534,8 +2535,12 @@ def main():
parser.add_argument('--cors', default=None, help='Allowed CORS origin (default: reflect request Origin header)')
args = parser.parse_args()

global ALLOWED_ORIGIN
global ALLOWED_ORIGIN, _DASHBOARD_PORT, _DEFAULT_ORIGINS
ALLOWED_ORIGIN = args.cors
_DASHBOARD_PORT = args.port
_DEFAULT_ORIGINS = _DEFAULT_ORIGINS | {
f'http://127.0.0.1:{args.port}', f'http://localhost:{args.port}',
}

server = HTTPServer((args.host, args.port), Handler)
log.info(f'三省六部看板启动 → http://{args.host}:{args.port}')
Expand Down
3 changes: 2 additions & 1 deletion scripts/run_loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ rotate_log() {
SCAN_INTERVAL="${2:-120}" # 巡检间隔(秒), 默认 120
SCAN_COUNTER=0
SCRIPT_TIMEOUT=30 # 单个脚本最大执行时间(秒)
DASHBOARD_PORT="${EDICT_DASHBOARD_PORT:-7891}" # 看板端口,可通过环境变量覆盖

echo "🏛️ 三省六部数据刷新循环启动 (PID=$$)"
echo " 脚本目录: $SCRIPT_DIR"
Expand Down Expand Up @@ -79,7 +80,7 @@ while true; do
SCAN_COUNTER=$((SCAN_COUNTER + INTERVAL))
if (( SCAN_COUNTER >= SCAN_INTERVAL )); then
SCAN_COUNTER=0
curl -s -X POST http://127.0.0.1:7891/api/scheduler-scan \
curl -s -X POST "http://127.0.0.1:${DASHBOARD_PORT}/api/scheduler-scan" \
-H 'Content-Type: application/json' -d '{"thresholdSec":180}' >> "$LOG" 2>&1 || true
fi

Expand Down