Skip to content

Commit

Permalink
Merge pull request #117 from myyrakle/feat/#116
Browse files Browse the repository at this point in the history
[#116] LAUNCHD_DAEMON_SCRIPT 상수를 정의하여 사용합니다.
  • Loading branch information
DPS0340 authored Jul 9, 2024
2 parents 0004841 + 0df3e09 commit 5e970d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
24 changes: 24 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,27 @@ StandardError=file:/var/log/rrdb.stderr.log
[Install]
WantedBy=multi-user.target"#;

#[cfg(target_os = "macos")]
pub const LAUNCHD_DAEMON_SCRIPT: &str = r#"<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>myyrakle.github.io.rrdb</string>
<key>UserName</key>
<string>root</string>
<key>Program</key>
<string>/usr/local/bin/rrdb</string>
<key>ProgramArguments</key>
<array>
<string>run</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/var/log/rrdb.stdout.log</string>
<key>StandardErrorPath</key>
<string>/var/log/rrdb.stderr.log</string>
</dict>
</plist>"#;
29 changes: 5 additions & 24 deletions src/executor/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,31 +108,12 @@ impl Executor {

#[cfg(target_os = "macos")]
async fn create_daemon_config_if_not_exists(&self) -> Result<(), RRDBError> {
use crate::constants::LAUNCHD_DAEMON_SCRIPT;

let base_path = PathBuf::from(LAUNCHD_PLIST_PATH);
let script = r#"<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>myyrakle.github.io.rrdb</string>
<key>UserName</key>
<string>root</string>
<key>Program</key>
<string>/usr/local/bin/rrdb</string>
<key>ProgramArguments</key>
<array>
<string>run</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/var/log/rrdb.stdout.log</string>
<key>StandardErrorPath</key>
<string>/var/log/rrdb.stderr.log</string>
</dict>
</plist>"#;

self.write_and_check_err(base_path, script).await

self.write_and_check_err(base_path, LAUNCHD_DAEMON_SCRIPT)
.await
}

#[cfg(target_os = "windows")]
Expand Down

0 comments on commit 5e970d4

Please sign in to comment.