diff --git a/infra.yml b/infra.yml
index 5c17d4d..18e2225 100755
--- a/infra.yml
+++ b/infra.yml
@@ -43,6 +43,8 @@
- { role: infra ,tags: infra } # setup infra components
# node-monitor
- { role: node_monitor ,tags: monitor } # init node exporter & vector
+ # insight
+ - { role: insight ,tags: insight } # setup insight workbench
#--------------------------------------------------------------#
diff --git a/roles/infra/templates/caddy/Caddyfile b/roles/infra/templates/caddy/Caddyfile
index 897f25c..665d5a0 100644
--- a/roles/infra/templates/caddy/Caddyfile
+++ b/roles/infra/templates/caddy/Caddyfile
@@ -23,6 +23,13 @@
reverse_proxy 127.0.0.1:4318
}
+ # -------------------------
+ # Insight Workbench
+ # -------------------------
+ handle_path /insight/* {
+ reverse_proxy 127.0.0.1:{{ workbench_port | default('8080') }}
+ }
+
# -------------------------
# Grafana: /ui/ 与 /ui/api/live/
# -------------------------
@@ -127,8 +134,11 @@
root * /www
file_server browse
+ @home path /
+ redir @home /insight 301
+
@zh path /zh
- rewrite @zh /zh.html
+ redir @zh /insight 301
@pev path /pev
rewrite @pev /pev.html
diff --git a/roles/insight/defaults/main.yml b/roles/insight/defaults/main.yml
new file mode 100644
index 0000000..9abcca2
--- /dev/null
+++ b/roles/insight/defaults/main.yml
@@ -0,0 +1,17 @@
+---
+#-----------------------------------------------------------------
+# INSIGHT - Observability Workbench
+#-----------------------------------------------------------------
+insight_enabled: true # enable insight workbench?
+workbench_port: 8080 # workbench listen port
+workbench_dir: /data/workbench # workbench deployment directory
+workbench_user: "{{ node_user | default('root') }}"
+workbench_group: "{{ node_user | default('root') }}"
+
+# nodejs version and registry
+nodejs_version: 20
+nodejs_registry: https://registry.npmmirror.com
+
+# build options
+workbench_clean: false # clean workbench directory before deployment?
+workbench_build: true # run npm install & build during setup?
diff --git a/roles/insight/tasks/main.yml b/roles/insight/tasks/main.yml
new file mode 100644
index 0000000..4b020cf
--- /dev/null
+++ b/roles/insight/tasks/main.yml
@@ -0,0 +1,81 @@
+---
+#--------------------------------------------------------------#
+# INSIGHT - Observability Workbench Deployment
+#--------------------------------------------------------------#
+
+- name: install nodejs and build tools
+ tags: insight_pkg
+ package:
+ name:
+ - nodejs
+ - npm
+ - gcc-c++
+ - make
+ state: present
+
+- name: create workbench directory
+ tags: insight_dir
+ file:
+ path: "{{ workbench_dir }}"
+ state: directory
+ owner: "{{ workbench_user }}"
+ group: "{{ workbench_group }}"
+ mode: '0755'
+
+- name: sync workbench source code
+ tags: insight_sync
+ synchronize:
+ src: "{{ playbook_dir }}/workbench/"
+ dest: "{{ workbench_dir }}/"
+ delete: yes
+ recursive: yes
+ rsync_opts:
+ - "--exclude=.next"
+ - "--exclude=node_modules"
+ - "--exclude=.git"
+
+- name: install npm dependencies
+ tags: insight_build
+ when: workbench_build|bool
+ npm:
+ path: "{{ workbench_dir }}"
+ registry: "{{ nodejs_registry }}"
+ environment: "{{ proxy_env | default({}) }}"
+
+- name: build nextjs workbench
+ tags: insight_build
+ when: workbench_build|bool
+ shell: npm run build
+ args:
+ chdir: "{{ workbench_dir }}"
+ executable: /bin/bash
+ environment:
+ PATH: "/usr/local/bin:/usr/bin:/bin"
+ NODE_ENV: production
+
+- name: render insight systemd service
+ tags: insight_config
+ template:
+ src: insight.service.j2
+ dest: /etc/systemd/system/insight.service
+ owner: root
+ group: root
+ mode: '0644'
+
+- name: launch insight service
+ tags: insight_launch
+ systemd:
+ name: insight
+ state: restarted
+ enabled: yes
+ daemon_reload: yes
+
+- name: wait for insight workbench
+ tags: insight_launch
+ wait_for:
+ host: 127.0.0.1
+ port: "{{ workbench_port }}"
+ state: started
+ timeout: 60
+
+...
diff --git a/roles/insight/templates/insight.service.j2 b/roles/insight/templates/insight.service.j2
new file mode 100644
index 0000000..1333e54
--- /dev/null
+++ b/roles/insight/templates/insight.service.j2
@@ -0,0 +1,17 @@
+[Unit]
+Description=Insight Workbench Service
+After=network.target
+
+[Service]
+Type=simple
+User={{ workbench_user }}
+Group={{ workbench_group }}
+WorkingDirectory={{ workbench_dir }}
+Environment=PORT={{ workbench_port }}
+Environment=NODE_ENV=production
+ExecStart=/usr/bin/npm start
+Restart=always
+RestartSec=10
+
+[Install]
+WantedBy=multi-user.target
diff --git a/workbench/next.config.mjs b/workbench/next.config.mjs
index df1417a..74b020a 100644
--- a/workbench/next.config.mjs
+++ b/workbench/next.config.mjs
@@ -11,6 +11,7 @@ const nextConfig = {
// ===============================
output: "standalone", // 让 Next.js 生成可独立运行的最小产物(大幅减小 Docker 镜像)
compress: true, // Gzip 压缩输出(确保小体积网络传输)
+ basePath: "/insight", // 👈 所有的路由都会带有 /insight 前缀
// 配置允许的外部图片域名
images: {
diff --git a/workbench/src/app/insight-temp-page.tsx b/workbench/src/app/insight-temp-page.tsx
deleted file mode 100644
index e375a97..0000000
--- a/workbench/src/app/insight-temp-page.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import { notFound } from 'next/navigation'
-
-import InsightWorkbench from './InsightWorkbench'
-import { isFeatureEnabled } from '@lib/featureToggles'
-
-export default function InsightPage() {
- if (!isFeatureEnabled('appModules', '/insight')) {
- notFound()
- }
-
- return
-}
diff --git a/workbench/src/app/insight/page.tsx b/workbench/src/app/insight/page.tsx
deleted file mode 100644
index 67e90fd..0000000
--- a/workbench/src/app/insight/page.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-"use client";
-
-import InsightWorkbench from "@/components/insight/InsightWorkbench";
-
-export default function InsightPage() {
- return ;
-}
diff --git a/workbench/src/app/page.tsx b/workbench/src/app/page.tsx
index 06f046e..8840400 100644
--- a/workbench/src/app/page.tsx
+++ b/workbench/src/app/page.tsx
@@ -1,5 +1,7 @@
-import { redirect } from "next/navigation";
+"use client";
+
+import InsightWorkbench from "@/components/insight/InsightWorkbench";
export default function Home() {
- redirect("/insight");
+ return ;
}