Skip to content

Commit

Permalink
add retry logic to the client so we can deploy during a push
Browse files Browse the repository at this point in the history
  • Loading branch information
gschoeni committed Jul 7, 2022
1 parent 4a0d137 commit 534a1d4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ FROM debian:bullseye-slim AS runtime
WORKDIR /oxen-server
COPY --from=builder /usr/src/oxen-server/target/release/oxen-server /usr/local/bin
ENV SYNC_DIR=/var/oxen/data
EXPOSE 3000
CMD ["oxen-server", "start"]
EXPOSE 3001
CMD ["oxen-server", "start", "-p", "3001"]
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.8
# Enables the web UI and tells Traefik to listen to docker
command: --providers.docker # --api.insecure=true
ports:
# The HTTP port
- "3000:80"
# The Web UI (enabled by --api.insecure=true)
# - "8080:8080"
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik.yml:/traefik.yml
oxen:
image: oxen/server:0.1.3
volumes:
Expand Down
17 changes: 16 additions & 1 deletion src/lib/src/index/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use indicatif::ProgressBar;
use rayon::prelude::*;
use std::fs;
use std::path::Path;
use std::{thread, time};

use crate::api;
use crate::constants::HISTORY_DIR;
Expand Down Expand Up @@ -206,7 +207,21 @@ impl Indexer {
match self.push_entry(&entry_writer, entry) {
Ok(_) => {}
Err(err) => {
log::error!("Error pushing entry {:?} Err {}", entry, err)
// Retry logic
let total_tries = 3;
let mut num_tries = 0;
for i in 0..total_tries {
let duration = time::Duration::from_secs(i+1);
thread::sleep(duration);
if let Ok(_) = self.push_entry(&entry_writer, entry) {
break;
}
num_tries += 1;
}

if num_tries == total_tries {
log::error!("Error pushing entry {:?} Err {}", entry, err);
}
}
}
bar.inc(1);
Expand Down
11 changes: 11 additions & 0 deletions traefik.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# log:
# level: DEBUG
# filepath: "/etc/traefik/log/traefik.log"
api:
dashboard: true
insecure: false
debug: true
providers:
docker:
exposedByDefault: false

0 comments on commit 534a1d4

Please sign in to comment.