2
0

align log shipping start/stop messages between producer and consumer

also there's no need to make it configurable, so get rid of that
This commit is contained in:
2025-10-26 20:41:19 +00:00
parent ad9bba4f93
commit 26e1608fa7
2 changed files with 8 additions and 17 deletions
+3 -3
View File
@@ -35,11 +35,11 @@
(tonumber (slurp stampfile))
0))
(each [l (: (io.input) :lines "L")]
(each [l (: (io.input) :lines "L")]
(case l
"START SHIPPING"
"# LOG-SHIPPING-START\n"
(set backfill? false)
"STOP SHIPPING"
"# LOG-SHIPPING-STOP\n"
(set backfill? true)
message
(let [message-ts (parse-timestamp message)]
+5 -14
View File
@@ -40,7 +40,8 @@ struct pollfd fds[] = {
{ .fd = -1, .events = POLLERR },
};
char *start_cookie, *stop_cookie;
#define START_SENTINEL "# LOG-SHIPPING-START\n"
#define STOP_SENTINEL "# LOG-SHIPPING-STOP\n"
static int fifo_connected(void)
{
@@ -77,7 +78,7 @@ int open_shipper_fifo(char* pathname)
/* write cookie to stdout so that the backfill process knows
* we are now logging realtime
*/
write(fds[1].fd, start_cookie, strlen(start_cookie));
write(fds[1].fd, START_SENTINEL, sizeof START_SENTINEL);
} else {
fifo_retry_timeout = FIFO_RETRY_TIMEOUT_MAX;
}
@@ -93,18 +94,8 @@ int main(int argc, char* argv[])
int tee_bytes = 0;
if (argc != 3) {
error(1, 0, "usage: " PROGRAM_NAME " /path/to/fifo cookie-text");
error(1, 0, "usage: " PROGRAM_NAME " /path/to/fifo");
}
char* cookie = argv[2];
start_cookie = malloc(strlen(cookie) + 9);
stop_cookie = malloc(strlen(cookie) + 8);
strcpy(start_cookie, "\n");
strcat(start_cookie, cookie);
strcat(start_cookie, " START\n");
strcpy(stop_cookie, "\n");
strcat(stop_cookie, cookie);
strcat(stop_cookie, " STOP\n");
signal(SIGPIPE, SIG_IGN);
@@ -127,7 +118,7 @@ int main(int argc, char* argv[])
tee_bytes = 0;
/* FIXME: nonblocking write, if stdout is not ready
* we will lose the message */
(void)write(1, stop_cookie, strlen(stop_cookie));
(void) write(1, STOP_SENTINEL, sizeof STOP_SENTINEL);
fifo_retry_timeout = FIFO_RETRY_TIMEOUT_MAX;
};