add option to disable listeners
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
e56d3c6cb3
commit
5167e1f06d
3 changed files with 20 additions and 4 deletions
|
@ -1503,6 +1503,11 @@
|
||||||
#
|
#
|
||||||
#sender_workers = 0
|
#sender_workers = 0
|
||||||
|
|
||||||
|
# Enables listener sockets; can be set to false to disable listening. This
|
||||||
|
# option is intended for developer/diagnostic purposes only.
|
||||||
|
#
|
||||||
|
#listening = true
|
||||||
|
|
||||||
[global.tls]
|
[global.tls]
|
||||||
|
|
||||||
# Path to a valid TLS certificate file.
|
# Path to a valid TLS certificate file.
|
||||||
|
|
|
@ -1710,6 +1710,11 @@ pub struct Config {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub sender_workers: usize,
|
pub sender_workers: usize,
|
||||||
|
|
||||||
|
/// Enables listener sockets; can be set to false to disable listening. This
|
||||||
|
/// option is intended for developer/diagnostic purposes only.
|
||||||
|
#[serde(default = "true_fn")]
|
||||||
|
pub listening: bool,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
#[allow(clippy::zero_sized_map_values)]
|
#[allow(clippy::zero_sized_map_values)]
|
||||||
// this is a catchall, the map shouldn't be zero at runtime
|
// this is a catchall, the map shouldn't be zero at runtime
|
||||||
|
|
|
@ -6,7 +6,7 @@ mod unix;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use axum_server::Handle as ServerHandle;
|
use axum_server::Handle as ServerHandle;
|
||||||
use conduwuit::Result;
|
use conduwuit::{err, Result};
|
||||||
use conduwuit_service::Services;
|
use conduwuit_service::Services;
|
||||||
use tokio::sync::broadcast;
|
use tokio::sync::broadcast;
|
||||||
|
|
||||||
|
@ -16,13 +16,19 @@ use super::layers;
|
||||||
pub(super) async fn serve(
|
pub(super) async fn serve(
|
||||||
services: Arc<Services>,
|
services: Arc<Services>,
|
||||||
handle: ServerHandle,
|
handle: ServerHandle,
|
||||||
shutdown: broadcast::Receiver<()>,
|
mut shutdown: broadcast::Receiver<()>,
|
||||||
) -> Result<()> {
|
) -> Result {
|
||||||
let server = &services.server;
|
let server = &services.server;
|
||||||
let config = &server.config;
|
let config = &server.config;
|
||||||
|
if !config.listening {
|
||||||
|
return shutdown
|
||||||
|
.recv()
|
||||||
|
.await
|
||||||
|
.map_err(|e| err!(error!("channel error: {e}")));
|
||||||
|
}
|
||||||
|
|
||||||
let addrs = config.get_bind_addrs();
|
let addrs = config.get_bind_addrs();
|
||||||
let (app, _guard) = layers::build(&services)?;
|
let (app, _guard) = layers::build(&services)?;
|
||||||
|
|
||||||
if cfg!(unix) && config.unix_socket_path.is_some() {
|
if cfg!(unix) && config.unix_socket_path.is_some() {
|
||||||
unix::serve(server, app, shutdown).await
|
unix::serve(server, app, shutdown).await
|
||||||
} else if config.tls.certs.is_some() {
|
} else if config.tls.certs.is_some() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue