This commit is contained in:
Adrian Heine 2017-05-09 13:39:05 +02:00
parent 2c7b5bd865
commit 8e848fc104
9 changed files with 133 additions and 12 deletions

View file

@ -1,2 +1 @@
pub mod reload;
pub mod server;

View file

@ -1,34 +0,0 @@
use std::error::Error;
use std::fmt;
use command_runner::CommandRunner;
use symbols::Symbol;
pub struct NginxReload<'a> {
command_runner: &'a CommandRunner,
}
impl<'a> NginxReload<'a> {
pub fn new(command_runner: &'a CommandRunner) -> Self {
NginxReload {
command_runner: command_runner
}
}
}
impl<'a> Symbol for NginxReload<'a> {
fn target_reached(&self) -> Result<bool, Box<Error>> {
Ok(true)
}
fn execute(&self) -> Result<(), Box<Error>> {
try!(self.command_runner.run_with_args("systemctl", &["reload-or-restart", "nginx"]));
Ok(())
}
}
impl<'a> fmt::Display for NginxReload<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(),fmt::Error>{
write!(f, "Reload nginx server")
}
}

View file

@ -100,6 +100,18 @@ location @proxy {{
NginxServer::new(domain, content, command_runner)
}
pub fn new_php(domain: &'a str, socket_path: &'a str, static_path: &'a str, command_runner: &'a CommandRunner) -> Self {
let content = NginxServer::server_config(domain, &format!("
root {};
index index.html index.php;
location ~ [^/]\\.php(/|$) {{
fastcgi_pass unix:{};
include \"snippets/fastcgi-php.conf\";
}}
", static_path, socket_path));
NginxServer::new(domain, content, command_runner)
}
pub fn new_static(domain: &'a str, static_path: &'a str, command_runner: &'a CommandRunner) -> Self {
let content = NginxServer::server_config(domain, &format!("
root {};