More flexible PHP FPM pool config

This commit is contained in:
Adrian Heine 2021-12-17 10:36:15 +01:00
parent e8b2f9fc5c
commit 21018bd6f6
4 changed files with 61 additions and 17 deletions

View file

@ -2,6 +2,7 @@ use crate::artifacts::{
DatabaseName as DatabaseNameArtifact, Path as PathArtifact, ServiceName as ServiceNameArtifact,
UserName as UserNameArtifact,
};
use crate::templates::php::FpmPoolConfig;
use std::hash::Hash;
use std::path::PathBuf;
@ -146,8 +147,14 @@ impl<D> Resource for ServeCustom<D> {
}
#[derive(Debug, Hash, PartialEq, Eq)]
pub struct ServePhp<D, P>(pub D, pub P, pub &'static str, pub String, pub usize);
impl<D, P> Resource for ServePhp<D, P> {
pub struct ServePhp<D, P, C>(
pub D,
pub P,
pub &'static str,
pub String,
pub C,
);
impl<D, P, C> Resource for ServePhp<D, P, C> {
type Artifact = PathArtifact;
}
@ -177,7 +184,7 @@ impl Resource for DefaultServer {
}
#[derive(Debug, Hash, PartialEq, Eq)]
pub struct PhpFpmPool<D>(pub D, pub usize);
pub struct PhpFpmPool<D>(pub D, pub FpmPoolConfig);
impl<D> Resource for PhpFpmPool<D> {
type Artifact = (
PathArtifact,
@ -275,6 +282,7 @@ macro_rules! default_resources {
}
}
// Only one enum entry per resource type, otherwise the equality checks fail
default_resources!(
AcmeAccountKey: AcmeAccountKey,
AcmeChallengesDir: AcmeChallengesDir,
@ -301,7 +309,7 @@ default_resources!(
PhpFpmPool: PhpFpmPool<D>,
ServeCustom: ServeCustom<D>,
ServeService: ServeService<D, PathBuf>,
ServePhp: ServePhp<D, PathBuf>,
ServePhp: ServePhp<D, PathBuf, FpmPoolConfig>,
ServeRedir: ServeRedir<D>,
ServeStatic: ServeStatic<D, PathBuf>,
StoredDirectory: StoredDirectory<PathBuf>,
@ -310,3 +318,8 @@ default_resources!(
WordpressPlugin: WordpressPlugin<PathBuf>,
WordpressTranslation: WordpressTranslation<PathBuf>,
);
pub fn serve_php<D, P: Into<PathBuf>, C: Into<FpmPoolConfig>>(domain: D, path: P, root_filename: &'static str, nginx_config: impl Into<String>, pool_config: C) -> ServePhp<D, PathBuf, FpmPoolConfig> {
ServePhp(
domain, path.into(), root_filename, nginx_config.into(), pool_config.into())
}