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

clerk authentication, max client retry and close connection #70

Closed
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
2 changes: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FROM node:lts-alpine as frontend
RUN apk --no-cache add git
WORKDIR /usr/src/app
COPY . .
RUN npm ci
RUN npm ci --force
RUN npm run build

FROM alpine:latest
Expand Down
7 changes: 7 additions & 0 deletions crates/sshx/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl Controller {
pub async fn run(&mut self) -> ! {
let mut last_retry = Instant::now();
let mut retries = 0;
let max_retries = 7; // 63 seconds of total retry time
loop {
if let Err(err) = self.try_channel().await {
if last_retry.elapsed() >= Duration::from_secs(10) {
Expand All @@ -111,6 +112,12 @@ impl Controller {
error!(%err, "disconnected, retrying in {secs}s...");
time::sleep(Duration::from_secs(secs)).await;
retries += 1;

if retries >= max_retries {
error!("max retries exceeded, closing session");
self.close().await.ok();
std::process::exit(1);
}
}
last_retry = Instant::now();
}
Expand Down
Loading
Loading