-
Notifications
You must be signed in to change notification settings - Fork 86
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
dns: wait for aardvark server just after spawning aardvark-dns
.
#300
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ use std::net::IpAddr; | |
use std::net::Ipv4Addr; | ||
use std::path::Path; | ||
use std::process::{Command, Stdio}; | ||
use std::{thread, time}; | ||
|
||
const SYSTEMD_CHECK_PATH: &str = "/run/systemd/system"; | ||
const SYSTEMD_RUN: &str = "systemd-run"; | ||
|
@@ -76,9 +77,8 @@ impl Aardvark { | |
false | ||
} | ||
|
||
pub fn start_aardvark_server(&self) -> Result<()> { | ||
pub fn start_aardvark_server(&mut self) -> Result<()> { | ||
log::debug!("Spawning aardvark server"); | ||
|
||
let mut aardvark_args = vec![]; | ||
// only use systemd when it is booted, see sd_booted(3) | ||
if Path::new(SYSTEMD_CHECK_PATH).exists() && Aardvark::is_executable_in_path(SYSTEMD_RUN) { | ||
|
@@ -115,6 +115,24 @@ impl Aardvark { | |
.env("RUST_LOG", log::max_level().as_str()) | ||
.spawn()?; | ||
|
||
// Starting aardvark server is the last task for netavark so in some env | ||
// setup netavark will end up exiting way sooner then aardvark process | ||
// is actually ready to serve so after starting aardvark we have to wait | ||
// till aardvark process is ready. If it does not shows up atleast retry | ||
// 10 times with a delay of 500ms and then return. | ||
let mut retry_count = 10; | ||
while retry_count > 0 { | ||
let aardvark_pid = self.get_aardvark_pid(); | ||
if aardvark_pid != -1 | ||
&& signal::kill(Pid::from_raw(aardvark_pid), Signal::SIGHUP).is_ok() | ||
{ | ||
break; | ||
} | ||
let duration_millis = time::Duration::from_millis(500); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 500ms is a little coarse. Recommend adjusting down to 250ms and doubling retries. |
||
thread::sleep(duration_millis); | ||
retry_count -= 1; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid SIGHUP, send signal 0 if possible - it takes no action on the target process, just returns if the process is alive.