Use OsStr for systemd unit exec value
This commit is contained in:
parent
36b85ff350
commit
d363254f6e
3 changed files with 10 additions and 8 deletions
|
|
@ -456,11 +456,11 @@ impl<D, P: AsRef<Path>> ImplementationBuilder<SystemdSocketService<D, P>> for De
|
|||
FileSymbol::new(
|
||||
conf_path.clone_rc(),
|
||||
if resource.4 {
|
||||
systemd_nodejs_service(&resource.2, socket_path, &resource.3)
|
||||
systemd_nodejs_service(resource.2.as_ref(), socket_path, &resource.3)
|
||||
} else {
|
||||
systemd_socket_service(
|
||||
socket_path,
|
||||
resource.2.as_ref().to_str().unwrap(),
|
||||
&resource.2,
|
||||
&resource.3,
|
||||
"",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use crate::artifacts::{
|
|||
use crate::templates::php::FpmPoolConfig;
|
||||
use std::hash::Hash;
|
||||
use std::path::Path;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
pub trait Resource {
|
||||
type Artifact;
|
||||
|
|
@ -136,7 +137,7 @@ impl Resource for User {
|
|||
}
|
||||
|
||||
#[derive(Debug, Hash, PartialEq, Eq)]
|
||||
pub struct SystemdSocketService<D, P>(pub D, pub &'static str, pub P, pub P, pub bool);
|
||||
pub struct SystemdSocketService<D, P>(pub D, pub &'static str, pub Rc<OsStr>, pub P, pub bool);
|
||||
impl<D, P> Resource for SystemdSocketService<D, P> {
|
||||
type Artifact = (PathArtifact, PathArtifact, UserNameArtifact);
|
||||
}
|
||||
|
|
@ -179,7 +180,7 @@ impl<D, P, C> Resource for ServePhp<D, P, C> {
|
|||
|
||||
// Domain, service name, exec, static, dir
|
||||
#[derive(Debug, Hash, PartialEq, Eq)]
|
||||
pub struct ServeService<D, P>(pub D, pub &'static str, pub P, pub P, pub P, pub bool);
|
||||
pub struct ServeService<D, P>(pub D, pub &'static str, pub Rc<OsStr>, pub P, pub P, pub bool);
|
||||
impl<D, P> Resource for ServeService<D, P> {
|
||||
type Artifact = PathArtifact;
|
||||
}
|
||||
|
|
@ -187,7 +188,7 @@ impl<D> ServeService<D, Rc<Path>> {
|
|||
pub fn new(
|
||||
domain: D,
|
||||
service_name: &'static str,
|
||||
exec: impl Into<Rc<Path>>,
|
||||
exec: impl Into<Rc<OsStr>>,
|
||||
static_path: impl Into<Rc<Path>>,
|
||||
working_directory: impl Into<Rc<Path>>,
|
||||
is_nodejs: bool,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
use std::path::Path;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
pub fn socket_service(
|
||||
socket_path: impl AsRef<Path>,
|
||||
exec: &str,
|
||||
exec: &OsStr,
|
||||
dir: impl AsRef<Path>,
|
||||
additional: &str,
|
||||
) -> String {
|
||||
|
|
@ -18,7 +19,7 @@ Restart=always
|
|||
WantedBy=default.target
|
||||
",
|
||||
socket_path.as_ref().to_str().unwrap(),
|
||||
exec,
|
||||
exec.display(),
|
||||
dir.as_ref().to_str().unwrap(),
|
||||
additional
|
||||
)
|
||||
|
|
@ -31,7 +32,7 @@ pub fn nodejs_service<N: AsRef<Path>, S: AsRef<Path>>(
|
|||
) -> String {
|
||||
socket_service(
|
||||
&socket_path,
|
||||
&format!("/usr/bin/nodejs {}", nodejs_path.as_ref().to_str().unwrap()),
|
||||
format!("/usr/bin/nodejs {}", nodejs_path.as_ref().to_str().unwrap()).as_ref(),
|
||||
dir,
|
||||
&format!(
|
||||
"Environment=NODE_ENV=production
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue