From bae12fca9945c0b75b5f494505b61a2b382f4d7b Mon Sep 17 00:00:00 2001 From: Cluas Date: Thu, 13 Apr 2023 00:29:43 +0800 Subject: [PATCH] feat: set keepalive for pgcat server itself (#402) * feat: set keepalive for pgcat server self * docs: note also set for client --- CONFIG.md | 4 ++-- src/main.rs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CONFIG.md b/CONFIG.md index 667daf1..613da75 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -1,4 +1,4 @@ -# PgCat Configurations +# PgCat Configurations ## `general` Section ### host @@ -127,7 +127,7 @@ path: general.tcp_keepalives_idle default: 5 ``` -Number of seconds of connection idleness to wait before sending a keepalive packet to the server. +Number of seconds of connection idleness to wait before sending a keepalive packet to the server and client. ### tcp_keepalives_count ``` diff --git a/src/main.rs b/src/main.rs index acd1935..b3265ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,6 +79,7 @@ mod stats; mod tls; use crate::config::{get_config, reload_config, VERSION}; +use crate::messages::configure_socket; use crate::pool::{ClientServerMap, ConnectionPool}; use crate::prometheus::start_metric_server; use crate::stats::{Collector, Reporter, REPORTER}; @@ -289,6 +290,8 @@ fn main() -> Result<(), Box> { let tls_certificate = get_config().general.tls_certificate.clone(); + configure_socket(&socket); + tokio::task::spawn(async move { let start = chrono::offset::Utc::now().naive_utc();