mirror of
https://git.robbyzambito.me/zaprus
synced 2026-02-04 00:14:52 +00:00
Retry timing
Wait 2 minutes if trying for initial connect. Wait 10 minutes if connection to sentinel has timed out
This commit is contained in:
14
src/main.zig
14
src/main.zig
@@ -126,6 +126,8 @@ pub fn main(init: std.process.Init) !void {
|
||||
return;
|
||||
}
|
||||
|
||||
var retry_seconds: u16 = 120;
|
||||
|
||||
if (flags.connect != null) {
|
||||
reconnect: while (true) {
|
||||
log.debug("Starting connection", .{});
|
||||
@@ -133,14 +135,22 @@ pub fn main(init: std.process.Init) !void {
|
||||
var init_con_buf: [SaprusClient.max_payload_len]u8 = undefined;
|
||||
var w: Writer = .fixed(&init_con_buf);
|
||||
try w.print("{b64}", .{flags.connect.?});
|
||||
var connection = try client.connect(init.io, w.buffered());
|
||||
var connection = client.connect(init.io, w.buffered()) catch {
|
||||
try init.io.sleep(.fromSeconds(retry_seconds), .boot);
|
||||
continue;
|
||||
};
|
||||
defer connection.deinit();
|
||||
|
||||
retry_seconds = 600;
|
||||
|
||||
log.debug("Connection started", .{});
|
||||
|
||||
while (true) {
|
||||
var res_buf: [2048]u8 = undefined;
|
||||
const next = connection.next(init.io, &res_buf) catch continue :reconnect;
|
||||
const next = connection.next(init.io, &res_buf) catch {
|
||||
try init.io.sleep(.fromSeconds(retry_seconds), .boot);
|
||||
continue :reconnect;
|
||||
};
|
||||
|
||||
const b64d = std.base64.standard.Decoder;
|
||||
var connection_payload_buf: [2048]u8 = undefined;
|
||||
|
||||
Reference in New Issue
Block a user