-
Notifications
You must be signed in to change notification settings - Fork 8
feat(service_manager):将发布系统接入服务管理模块 #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2166377
feat(部署): 重构部署任务管理功能
JaD1ng bdf837e
feat(deploy): 实现本地部署包支持及部署流程优化
JaD1ng 20c690f
fix(alert_service): 修复表达式重复添加比较操作符的问题
JaD1ng 41ba9ab
feat(grafana): 添加QPS监控面板并配置匿名访问
JaD1ng 22df443
增加一些测试脚本
JaD1ng e7daa5c
Merge branch 'develop' into feat/issue78
JaD1ng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- Deploy模块数据库架构 | ||
-- 部署相关的主机、实例和版本历史表 | ||
|
||
-- 创建hosts表:主机信息 | ||
CREATE TABLE hosts ( | ||
id SERIAL PRIMARY KEY, | ||
name VARCHAR(255) UNIQUE, | ||
ip_address VARCHAR(45) UNIQUE, | ||
is_stopped BOOLEAN | ||
); | ||
|
||
-- 创建instances表:服务实例信息 | ||
CREATE TABLE instances ( | ||
id VARCHAR(255) NOT NULL PRIMARY KEY, -- VARCHAR类型主键,非自增,不为空 | ||
service_name VARCHAR(255), | ||
service_version VARCHAR(255), | ||
host_id VARCHAR(255), | ||
host_ip_address VARCHAR(45), | ||
ip_address VARCHAR(45), | ||
port INT, | ||
status VARCHAR(50), | ||
is_stopped BOOLEAN, | ||
-- 保留ip_address和port的组合唯一约束 | ||
CONSTRAINT unique_ip_port UNIQUE (ip_address, port) | ||
); | ||
|
||
-- 1. 创建service_name和service_version的联合索引 | ||
CREATE INDEX idx_instances_service_name_version | ||
ON instances (service_name, service_version); | ||
|
||
-- 2. 创建service_name和ip_address的联合索引 | ||
CREATE INDEX idx_instances_service_name_ip | ||
ON instances (service_name, ip_address); | ||
|
||
-- 3. 创建version_histories表:版本历史记录 | ||
CREATE TABLE version_histories ( | ||
id SERIAL PRIMARY KEY, | ||
instance_id VARCHAR(255), | ||
service_name VARCHAR(255), | ||
service_version VARCHAR(255), | ||
status VARCHAR(50) | ||
); | ||
|
||
-- 初始化主机数据 | ||
-- 插入 jfcs1021 主机数据 | ||
INSERT INTO hosts (name, ip_address, is_stopped) | ||
VALUES ('jfcs1021', '10.210.10.33', false); | ||
|
||
-- 插入 jfcs1022 主机数据 | ||
INSERT INTO hosts (name, ip_address, is_stopped) | ||
VALUES ('jfcs1022', '10.210.10.30', false); | ||
|
||
-- 插入 jfcs1023 主机数据 | ||
INSERT INTO hosts (name, ip_address, is_stopped) | ||
VALUES ('jfcs1023', '10.210.10.31', false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
database: | ||
host: "localhost" | ||
port: 5432 | ||
user: "admin" | ||
password: "password" | ||
dbname: "zeroops" | ||
sslmode: "disable" | ||
|
||
privateKey: | | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIICXQIBAAKBgQDZsfv1qscqYdy4vY+P4e3cAtmvppXQcRvrF1cB4drkv0haU24Y | ||
7m5qYtT52Kr539RdbKKdLAM6s20lWy7+5C0DgacdwYWd/7PeCELyEipZJL07Vro7 | ||
Ate8Bfjya+wltGK9+XNUIHiumUKULW4KDx21+1NLAUeJ6PeW+DAkmJWF6QIDAQAB | ||
AoGBAJlNxenTQj6OfCl9FMR2jlMJjtMrtQT9InQEE7m3m7bLHeC+MCJOhmNVBjaM | ||
ZpthDORdxIZ6oCuOf6Z2+Dl35lntGFh5J7S34UP2BWzF1IyyQfySCNexGNHKT1G1 | ||
XKQtHmtc2gWWthEg+S6ciIyw2IGrrP2Rke81vYHExPrexf0hAkEA9Izb0MiYsMCB | ||
/jemLJB0Lb3Y/B8xjGjQFFBQT7bmwBVjvZWZVpnMnXi9sWGdgUpxsCuAIROXjZ40 | ||
IRZ2C9EouwJBAOPjPvV8Sgw4vaseOqlJvSq/C/pIFx6RVznDGlc8bRg7SgTPpjHG | ||
4G+M3mVgpCX1a/EU1mB+fhiJ2LAZ/pTtY6sCQGaW9NwIWu3DRIVGCSMm0mYh/3X9 | ||
DAcwLSJoctiODQ1Fq9rreDE5QfpJnaJdJfsIJNtX1F+L3YceeBXtW0Ynz2MCQBI8 | ||
9KP274Is5FkWkUFNKnuKUK4WKOuEXEO+LpR+vIhs7k6WQ8nGDd4/mujoJBr5mkrw | ||
DPwqA3N5TMNDQVGv8gMCQQCaKGJgWYgvo3/milFfImbp+m7/Y3vCptarldXrYQWO | ||
AQjxwc71ZGBFDITYvdgJM1MTqc8xQek1FXn1vfpy2c6O | ||
-----END RSA PRIVATE KEY----- | ||
Comment on lines
+9
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
// Config Deploy服务配置 | ||
type Config struct { | ||
Database DatabaseConfig `yaml:"database"` | ||
} | ||
|
||
// DatabaseConfig 数据库配置 | ||
type DatabaseConfig struct { | ||
Host string `yaml:"host"` | ||
Port int `yaml:"port"` | ||
User string `yaml:"user"` | ||
Password string `yaml:"password"` | ||
DBName string `yaml:"dbname"` | ||
SSLMode string `yaml:"sslmode"` | ||
} | ||
|
||
// GetDSN 获取PostgreSQL数据库连接字符串 | ||
func (d *DatabaseConfig) GetDSN() string { | ||
return fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s", | ||
d.Host, d.Port, d.User, d.Password, d.DBName, d.SSLMode) | ||
} | ||
|
||
// LoadConfig 加载配置文件 | ||
func LoadConfig(configPath string) (*Config, error) { | ||
data, err := os.ReadFile(configPath) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to read config file: %w", err) | ||
} | ||
|
||
var config Config | ||
if err := yaml.Unmarshal(data, &config); err != nil { | ||
return nil, fmt.Errorf("failed to parse config file: %w", err) | ||
} | ||
|
||
return &config, nil | ||
} |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
数据库列类型不匹配。
instances
表中的host_id
列定义为VARCHAR(255)
,但它似乎是作为外键关联到hosts
表的id
列。而hosts.id
列的类型是SERIAL
,即自增整数(integer
)。为了保证数据完整性和查询性能,建议将
host_id
的类型修改为INTEGER
或BIGINT
,并添加外键约束。