pub struct Server {
pub configuration: Arc<ServerConf>,
pub options: Option<Opt>,
/* private fields */
}
Expand description
The server object
This object represents an entire pingora server process which may have multiple independent services (see crate::services). The server object handles signals, reading configuration, zero downtime upgrade and error reporting.
Fields§
§configuration: Arc<ServerConf>
The parsed server configuration
options: Option<Opt>
The parser command line options
Implementations§
Source§impl Server
impl Server
Sourcepub fn new_with_opt_and_conf(
raw_opt: impl Into<Option<Opt>>,
conf: ServerConf,
) -> Server
pub fn new_with_opt_and_conf( raw_opt: impl Into<Option<Opt>>, conf: ServerConf, ) -> Server
Create a new Server
, using the Opt
and ServerConf
values provided
This method is intended for pingora frontends that are NOT using the built-in command line and configuration file parsing, and are instead using their own.
If a configuration file path is provided as part of opt
, it will be ignored
and a warning will be logged.
Sourcepub fn add_service(&mut self, service: impl Service + 'static)
pub fn add_service(&mut self, service: impl Service + 'static)
Add a service to this server.
A service is anything that implements Service
.
Sourcepub fn add_services(&mut self, services: Vec<Box<dyn Service>>)
pub fn add_services(&mut self, services: Vec<Box<dyn Service>>)
Similar to Self::add_service()
, but take a list of services
Sourcepub fn bootstrap(&mut self)
pub fn bootstrap(&mut self)
Prepare the server to start
When trying to zero downtime upgrade from an older version of the server which is already running, this function will try to get all its listening sockets in order to take them over.
Sourcepub fn run_forever(self) -> !
pub fn run_forever(self) -> !
Start the server
This function will block forever until the server needs to quit. So this would be the last function to call for this object.
Note: this function may fork the process for daemonization, so any additional threads created before this function will be lost to any service logic once this function is called.