mirror of
https://git.robbyzambito.me/zaprus/
synced 2026-02-04 03:34:48 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var retry_seconds: u16 = 120;
|
||||||
|
|
||||||
if (flags.connect != null) {
|
if (flags.connect != null) {
|
||||||
reconnect: while (true) {
|
reconnect: while (true) {
|
||||||
log.debug("Starting connection", .{});
|
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 init_con_buf: [SaprusClient.max_payload_len]u8 = undefined;
|
||||||
var w: Writer = .fixed(&init_con_buf);
|
var w: Writer = .fixed(&init_con_buf);
|
||||||
try w.print("{b64}", .{flags.connect.?});
|
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();
|
defer connection.deinit();
|
||||||
|
|
||||||
|
retry_seconds = 600;
|
||||||
|
|
||||||
log.debug("Connection started", .{});
|
log.debug("Connection started", .{});
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
var res_buf: [2048]u8 = undefined;
|
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;
|
const b64d = std.base64.standard.Decoder;
|
||||||
var connection_payload_buf: [2048]u8 = undefined;
|
var connection_payload_buf: [2048]u8 = undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user