feat: 更新 agent.json 配置,确保主配置路径为绝对路径,并添加 agent 状态文件

This commit is contained in:
ryan
2026-03-12 23:00:18 +08:00
parent eafcac87a4
commit a5da53a2fb
4 changed files with 21 additions and 3 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
{
"server_url": "http://127.0.0.1:3000",
"agent_token": "2bae8c0eef58c3d7cf84464d983052ca",
"data_dir": "./data",
"agent_token": "d873f8084cb7539a2d2f6273ba7fbebe",
"data_dir": "./data-v5test",
"openresty_container_name": "atsflare-openresty",
"openresty_docker_image": "openresty/openresty:alpine",
"heartbeat_interval": 30000,
@@ -0,0 +1,8 @@
{
"node_id": "node-f79896cc731413b3",
"current_version": "",
"current_checksum": "",
"last_error": "docker openresty -t failed: exit status 1: 2026/03/12 14:59:57 [emerg] 1#1: open() \"/usr/local/openresty/nginx/conf/data-v5test/etc/nginx/conf.d/atsflare_routes.conf\" failed (2: No such file or directory) in /usr/local/openresty/nginx/conf/nginx.conf:31\nnginx: [emerg] open() \"/usr/local/openresty/nginx/conf/data-v5test/etc/nginx/conf.d/atsflare_routes.conf\" failed (2: No such file or directory) in /usr/local/openresty/nginx/conf/nginx.conf:31\nnginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test failed\n",
"openresty_status": "unhealthy",
"openresty_message": "docker openresty -t failed: exit status 1: 2026/03/12 14:59:57 [emerg] 1#1: open() \"/usr/local/openresty/nginx/conf/data-v5test/etc/nginx/conf.d/atsflare_routes.conf\" failed (2: No such file or directory) in /usr/local/openresty/nginx/conf/nginx.conf:31\nnginx: [emerg] open() \"/usr/local/openresty/nginx/conf/data-v5test/etc/nginx/conf.d/atsflare_routes.conf\" failed (2: No such file or directory) in /usr/local/openresty/nginx/conf/nginx.conf:31\nnginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test failed\n"
}
+5 -1
View File
@@ -315,6 +315,10 @@ func NewExecutor(options ExecutorOptions) Executor {
Runner: runner,
}
}
mainConfigPath := options.MainConfigPath
if absPath, err := filepath.Abs(mainConfigPath); err == nil {
mainConfigPath = absPath
}
routeConfigDir := filepath.Dir(options.RouteConfigPath)
if absDir, err := filepath.Abs(routeConfigDir); err == nil {
routeConfigDir = absDir
@@ -327,7 +331,7 @@ func NewExecutor(options ExecutorOptions) Executor {
DockerBinary: options.DockerBinary,
ContainerName: options.ContainerName,
Image: options.Image,
MainConfigPath: options.MainConfigPath,
MainConfigPath: mainConfigPath,
RouteConfigDir: routeConfigDir,
CertDir: certDir,
NginxCertDir: options.NginxCertDir,
@@ -291,9 +291,15 @@ func TestNewExecutorUsesAbsoluteDockerMountPath(t *testing.T) {
if !filepath.IsAbs(dockerExecutor.RouteConfigDir) {
t.Fatalf("expected absolute route config dir, got %s", dockerExecutor.RouteConfigDir)
}
if !filepath.IsAbs(dockerExecutor.MainConfigPath) {
t.Fatalf("expected absolute main config path, got %s", dockerExecutor.MainConfigPath)
}
if !strings.HasSuffix(dockerExecutor.RouteConfigDir, filepath.Clean("data/etc/nginx/conf.d")) {
t.Fatalf("unexpected route config dir: %s", dockerExecutor.RouteConfigDir)
}
if !strings.HasSuffix(dockerExecutor.MainConfigPath, filepath.Clean("data/etc/nginx/nginx.conf")) {
t.Fatalf("unexpected main config path: %s", dockerExecutor.MainConfigPath)
}
}
func TestDetectVersionFromBinary(t *testing.T) {