Skip to content

Commit

Permalink
sleep for internet
Browse files Browse the repository at this point in the history
  • Loading branch information
Devin Brite committed Apr 13, 2024
1 parent 1553c18 commit 027c679
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dwbrite-com/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ common = { path = "../common" }
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0"
grass = "0.10.4"
structopt = "0.3.21"
structopt = "0.3.21"
5 changes: 3 additions & 2 deletions dwbrite-com/src/blog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl RawBlogPost {
fn codify_media(&mut self) {
let re = Regex::new(r#"<m src="(.*?)".*?>"#).unwrap();
let result = re.replace_all(&self.content, |caps: &Captures| -> String {
let mediadata_url = format!("http://media.dwbrite.com/registry/{}", &caps[1]);
let mediadata_url = format!("https://media.dwbrite.com/registry/{}", &caps[1]);

let mut option_data = None;
match reqwest::blocking::get(&mediadata_url) {
Expand All @@ -159,7 +159,8 @@ impl RawBlogPost {
let data: MediaData = serde_json::from_slice(bytes.to_vec().as_slice()).unwrap();
option_data = Some(data);
}
Err(_) => {
Err(e) => {
println!("REEEEEEEEEEEEEEE: {:?}", e);
return String::from("[Could not load media at startup. The media server may be down.]")
}
}
Expand Down
15 changes: 2 additions & 13 deletions dwbrite-com/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,8 @@ fn main() {

compile_sass().unwrap();

// wait for internet connectivity
loop {
match TcpStream::connect_timeout(&"8.8.8.8:53".parse().unwrap(), Duration::from_secs(1)) {
Ok(_) => {
println!("Internet connection is available.");
break;
}
Err(e) => {
println!("Waiting for internet connection... Error: {}", e);
thread::sleep(Duration::from_secs(1));
}
}
}
// wait for internet connectivity :')
thread::sleep(Duration::from_secs(15));

let opt = Opt::from_args();

Expand Down

0 comments on commit 027c679

Please sign in to comment.