diff --git a/atsf_agent/agent.json b/atsf_agent/agent.json index a436fe65..eb4f1d31 100644 --- a/atsf_agent/agent.json +++ b/atsf_agent/agent.json @@ -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, diff --git a/atsf_agent/data-v5test/var/lib/atsflare/agent-state.json b/atsf_agent/data-v5test/var/lib/atsflare/agent-state.json new file mode 100644 index 00000000..e84d0081 --- /dev/null +++ b/atsf_agent/data-v5test/var/lib/atsflare/agent-state.json @@ -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" +} \ No newline at end of file diff --git a/atsf_agent/internal/nginx/manager.go b/atsf_agent/internal/nginx/manager.go index 3ceb9baf..811a41f3 100644 --- a/atsf_agent/internal/nginx/manager.go +++ b/atsf_agent/internal/nginx/manager.go @@ -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, diff --git a/atsf_agent/internal/nginx/manager_test.go b/atsf_agent/internal/nginx/manager_test.go index 636da6cc..eeb9e579 100644 --- a/atsf_agent/internal/nginx/manager_test.go +++ b/atsf_agent/internal/nginx/manager_test.go @@ -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) {