周玉环 vor 6 Stunden
Ursprung
Commit
4e53efd173

+ 1 - 0
backend/.gitignore

@@ -41,6 +41,7 @@ pkg/generated
 data/etcd/
 data/glance/
 data/torrents/
+data/victoria-metrics
 logs/*.log
 logs/*.pid
 

+ 39 - 1
backend/dev-scripts/register-services.sh

@@ -87,11 +87,45 @@ VALUES
 ('compute-endpoint-internal', 'compute-service-id', 'default', 'internal', 'http://localhost:30888', 1, NOW(), NOW(), 0, 0, 'region'),
 ('compute-endpoint-admin', 'compute-service-id', 'default', 'admin', 'http://localhost:30888', 1, NOW(), NOW(), 0, 0, 'region');
 
--- 7. 注册 region 表(即使region服务未运行,也需要有region记录)
+-- 7. 注册 yunionagent 服务 (指向yunionconf)
+INSERT INTO service (id, name, type, enabled, created_at, updated_at, update_version, deleted, is_emulated, config_version)
+VALUES ('yunionagent-service-id', 'yunionagent', 'yunionagent', 1, NOW(), NOW(), 0, 0, 0, 0);
+
+INSERT INTO endpoint (id, service_id, region_id, interface, url, enabled, created_at, updated_at, update_version, deleted, name)
+VALUES 
+('yunionagent-endpoint-public', 'yunionagent-service-id', 'default', 'public', 'http://localhost:30889', 1, NOW(), NOW(), 0, 0, 'yunionagent'),
+('yunionagent-endpoint-internal', 'yunionagent-service-id', 'default', 'internal', 'http://localhost:30889', 1, NOW(), NOW(), 0, 0, 'yunionagent'),
+('yunionagent-endpoint-admin', 'yunionagent-service-id', 'default', 'admin', 'http://localhost:30889', 1, NOW(), NOW(), 0, 0, 'yunionagent');
+
+-- 8. 注册 victoria-metrics 服务 (时序数据库)
+INSERT INTO service (id, name, type, enabled, created_at, updated_at, update_version, deleted, is_emulated, config_version)
+VALUES ('victoria-metrics-service-id', 'victoria-metrics', 'victoria-metrics', 1, NOW(), NOW(), 0, 0, 0, 0);
+
+INSERT INTO endpoint (id, service_id, region_id, interface, url, enabled, created_at, updated_at, update_version, deleted, name)
+VALUES 
+('victoria-metrics-endpoint-public', 'victoria-metrics-service-id', 'default', 'public', 'http://localhost:8428', 1, NOW(), NOW(), 0, 0, 'victoria-metrics'),
+('victoria-metrics-endpoint-internal', 'victoria-metrics-service-id', 'default', 'internal', 'http://localhost:8428', 1, NOW(), NOW(), 0, 0, 'victoria-metrics'),
+('victoria-metrics-endpoint-admin', 'victoria-metrics-service-id', 'default', 'admin', 'http://localhost:8428', 1, NOW(), NOW(), 0, 0, 'victoria-metrics');
+
+-- 9. 注册 region 表(即使region服务未运行,也需要有region记录)
 INSERT INTO region (id, name, created_at, updated_at, update_version, deleted)
 VALUES ('default', 'default', NOW(), NOW(), 0, 0)
 ON DUPLICATE KEY UPDATE updated_at=NOW();
 
+-- 10. 初始化 global-settings 参数(前端需要)
+INSERT INTO paramters_tbl (id, name, service, value, created_at, updated_at, update_version, deleted)
+VALUES (
+    REPLACE(UUID(), '-', ''),
+    'global-settings',
+    'yunionagent',
+    '{"setupKeys":["zh-CN","en","ja-JP"],"productVersion":"CMP"}',
+    NOW(),
+    NOW(),
+    0,
+    0
+)
+ON DUPLICATE KEY UPDATE value='{"setupKeys":["zh-CN","en","ja-JP"],"productVersion":"CMP"}', updated_at=NOW();
+
 SELECT 'Services registered successfully' as status;
 SELECT COUNT(*) as service_count FROM service;
 SELECT COUNT(*) as endpoint_count FROM endpoint;
@@ -106,7 +140,11 @@ echo "  - identity (keystone) - http://localhost:35357/v3"
 echo "  - compute (region) - http://localhost:30888"
 echo "  - image (glance) - http://localhost:9292"
 echo "  - yunionconf - http://localhost:30889"
+echo "  - yunionagent - http://localhost:30889 (指向yunionconf)"
 echo "  - monitor - http://localhost:30093"
 echo "  - scheduledtask - http://localhost:30891"
+echo "  - victoria-metrics - http://localhost:8428"
+echo ""
+echo "✓ global-settings 参数已初始化"
 echo ""
 echo "注意: 需要重启服务以加载新的service catalog"

+ 14 - 3
backend/dev-scripts/start-services.sh

@@ -263,6 +263,18 @@ start_all() {
     else
         echo -e "${YELLOW}未找到 start-etcd.sh,跳过etcd启动${NC}"
     fi
+    
+    # 初始化 etcd 配置
+    echo -e "${YELLOW}初始化 etcd 配置...${NC}"
+    ETCDCTL="$BACKEND_DIR/bin/darwin/etcdctl"
+    if [ ! -f "$ETCDCTL" ]; then
+        # 尝试 Linux 版本
+        ETCDCTL="$BACKEND_DIR/bin/linux/etcdctl"
+    fi
+    if [ -f "$ETCDCTL" ]; then
+        $ETCDCTL --endpoints=http://localhost:2379 put unifiedmonitors '{"enabled":false}' > /dev/null 2>&1 || true
+        echo -e "${GREEN}✓ etcd 配置初始化完成${NC}"
+    fi
     echo ""
     
     # 第一阶段:启动keystone
@@ -304,9 +316,8 @@ start_all() {
     # yunionconf: 配置服务 (需要认证和数据库)
     start_service "yunionconf" 30889 true true
     
-    # monitor: 监控服务 (需要认证和数据库) - 暂时跳过,需要influxdb
-    # start_service "monitor" 30093 true true
-    echo -e "${YELLOW}  跳过 monitor (需要 influxdb/victoria-metrics)${NC}"
+    # monitor: 监控服务 (需要认证和数据库)
+    start_service "monitor" 30093 true true
     
     # scheduledtask: 定时任务服务 (需要认证和数据库)
     start_service "scheduledtask" 30891 true true

+ 25 - 3
frontend/vue.config.js

@@ -174,11 +174,13 @@ module.exports = {
    */
   devServer: Object.assign({
     overlay: {
-      warnings: true,
+      warnings: false,
       errors: true,
     },
     open: process.platform === 'darwin',
     port: 8080,
+    hot: true,
+    stats: 'minimal',
     proxy: {
       '/api': {
         target: 'http://localhost:30300',
@@ -188,8 +190,28 @@ module.exports = {
       },
     },
     watchOptions: {
-      aggregateTimeout: 600, // 当第一个文件更改,会在重新构建前增加延迟。这个选项允许 webpack 将这段时间内进行的任何其他更改都聚合到一次重新构建里。以毫秒为单位q
-      ignored: [/.git/, /node_modules/],
+      aggregateTimeout: 1000, // 1秒内的多次修改只触发一次编译
+      poll: false,
+      // 只监听源代码目录,忽略其他所有文件
+      ignored: [
+        /node_modules/,
+        /dist/,
+        /.cache/,
+        /.git/,
+        /\.DS_Store$/,
+        /\.log$/,
+        /\.pid$/,
+        /\.md$/,           // 忽略 markdown 文档
+        /\.json$/,         // 忽略配置文件(package.json等)
+        /\.yml$/,
+        /\.yaml$/,
+        /\.lock$/,
+        /\.gitignore$/,
+        /\.editorconfig$/,
+        /\.eslintrc/,
+        /\.prettierrc/,
+        /public\//,        // 忽略 public 目录
+      ],
     },
   }, devServerCoustomConfig),
 }