Skip to content

Commit 3c543e3

Browse files
committed
Allow the daemonbase::process::Process::Config struct fields to be set other than via Clap args or a ConfigFile object.
1 parent 038578e commit 3c543e3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/process.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,31 @@ mod unix {
467467
self.group = Some(group)
468468
}
469469
}
470+
471+
pub fn with_pid_file(mut self, v: ConfigPath) -> Self {
472+
self.pid_file = Some(v);
473+
self
474+
}
475+
476+
pub fn with_working_dir(mut self, v: ConfigPath) -> Self {
477+
self.working_dir = Some(v);
478+
self
479+
}
480+
481+
pub fn with_chroot(mut self, v: ConfigPath) -> Self {
482+
self.chroot = Some(v);
483+
self
484+
}
485+
486+
pub fn with_user(mut self, v: &str) -> Result<Self, String> {
487+
self.user = Some(UserId::from_str(v)?);
488+
Ok(self)
489+
}
490+
491+
pub fn with_group(mut self, v: &str) -> Result<Self, String> {
492+
self.group = Some(GroupId::from_str(v)?);
493+
Ok(self)
494+
}
470495
}
471496

472497

@@ -706,6 +731,26 @@ mod noop {
706731
pub fn apply_args(&mut self, args: Args) {
707732
let _ = args;
708733
}
734+
735+
pub fn with_pid_file(mut self, _: ConfigPath) -> Self {
736+
self
737+
}
738+
739+
pub fn with_working_dir(mut self, _: ConfigPath) -> Self {
740+
self
741+
}
742+
743+
pub fn with_chroot(mut self, _: ConfigPath) -> Self {
744+
self
745+
}
746+
747+
pub fn with_user(mut self, _: &str) -> Result<Self, String> {
748+
Ok(self)
749+
}
750+
751+
pub fn with_group(mut self, _: &str) -> Result<Self, String> {
752+
Ok(self)
753+
}
709754
}
710755

711756
//-------- Args ----------------------------------------------------------

0 commit comments

Comments
 (0)