This commit is contained in:
Adrian Heine 2017-04-09 16:07:33 +02:00
parent 1bb22db692
commit 7d629e38d8
14 changed files with 478 additions and 58 deletions

View file

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

View file

@ -0,0 +1,40 @@
use std::error::Error;
use std::fmt;
use std::io;
use std::ops::Deref;
use command_runner::CommandRunner;
use symbols::Symbol;
use symbols::file::File as FileSymbol;
use resources::Resource;
pub struct NginxReload<'a> {
command_runner: &'a CommandRunner,
}
use std::borrow::Cow;
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

@ -75,18 +75,23 @@ location @proxy {{
let content = String::from(redir_content) + &format!("server {{
listen 80;
# listen 443 ssl;
# ssl_certificate /etc/ssl/.crt;
# ssl_certificate_key /etc/ssl/.key;
listen 443 ssl;
ssl_certificate /etc/ssl/local_certs/{0}.crt;
ssl_certificate_key /etc/ssl/private/{0}.key;
server_name {};
root {};
include \"snippets/acme-challenge.conf\";
{}
}}
", domain, static_path, proxy_content);
NginxServer::new_generic(FileSymbol::new(file_path, content), command_runner)
}
pub fn new_generic(file: FileSymbol<String, Cow<'a, str>>, command_runner: &'a CommandRunner) -> Self {
NginxServer {
command_runner: command_runner,
file: FileSymbol::new(file_path, content)
file: file
}
}
}