Update
This commit is contained in:
parent
2c7b5bd865
commit
8e848fc104
9 changed files with 133 additions and 12 deletions
|
|
@ -1,2 +1 @@
|
|||
pub mod reload;
|
||||
pub mod server;
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue