ITADN

Piko Agent CLI seemingly does not wait for server to gracefully shutdown active connections

#290Closeddipack95 创建于 2025-11-21
D
dipack95commented
Hi Andy, We've recently noticed that the Piko agent we deploy alongside our applications that need reverse tunnelling, doesn't seem to wait for active connections to terminate before shutting down the reverseproxy Server. Poking around in the agent code, I found [this block](https://github.com/andydunstall/piko/blob/4a5649a5809b38b81a31bf5a91d3d5ce78125350/cli/agent/command.go#L174), where we probably need to change the `err != nil` is `err != http.ErrServerClosed` instead (from Go's [`http#Server.Shutdown` docs](https://pkg.go.dev/net/http#Server.Shutdown)), such that the HTTP server has had the time to terminate active connections gracefully. I can try to get a reproduction case working for you soon, but thought I'd open an issue here to verify my understanding. We start the Piko agent service using: `piko agent start --config.expand-env --config.path /etc/agent.yaml` <details> <summary>Our agent.yaml file</summary> ```yaml listeners: - endpoint_id: ${ID} addr: ${ADDRESS} timeout: ${LISTENER_TIMEOUT:5m} http_client: keep_alive_timeout: ${KEEP_ALIVE_TIMEOUT:11m} idle_conn_timeout: ${DIALER_IDLE_CONN_TIMEOUT:12m} max_idle_conns: -1 disable_compression: true access_log: level: ${LISTENER_LOG_LEVEL:info} request_headers: block_list: - X-Piko-Authorization response_headers: block_list: - Authorization - Set-Cookie protocol: http tls: root_cas: ${TLS_ROOT_CAS} insecure_skip_verify: ${TLS_INSECURE_SKIP_VERIFY:false} connect: url: ${PROXY_URL} timeout: 30s token: ${PROXY_TOKEN} server: enabled: false log: level: ${LOG_LEVEL:info} grace_period: ${GRACE_PERIOD:2m} ``` </details>
关闭于 2026-01-25 10 条评论