Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#116] LAUNCHD_DAEMON_SCRIPT 상수를 정의하여 사용합니다. #117

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading