-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
osdpctl: More WIP changes; CP and PD services work
Signed-off-by: Siddharth Chandrasekaran <[email protected]>
- Loading branch information
Showing
6 changed files
with
156 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use anyhow::Context; | ||
use daemonize::Daemonize; | ||
use std::path::Path; | ||
|
||
type Result<T> = anyhow::Result<T, anyhow::Error>; | ||
|
||
pub fn daemonize(runtime_dir: &Path, name: &str) -> Result<()> { | ||
let stdout = std::fs::File::create(runtime_dir.join(format!("dev-{}.out.log", name).as_str())) | ||
.context("Failed to create stdout for daemon")?; | ||
let stderr = std::fs::File::create(runtime_dir.join(format!("dev-{}.err.log", name).as_str())) | ||
.context("Failed to create stderr for daemon")?; | ||
let daemon = Daemonize::new() | ||
.pid_file(runtime_dir.join(format!("dev-{}.pid", name))) | ||
.chown_pid_file(true) | ||
.working_directory(runtime_dir) | ||
.stdout(stdout) | ||
.stderr(stderr); | ||
daemon.start().context("Failed to start daemon process")?; | ||
Ok(()) | ||
} |
Oops, something went wrong.