summaryrefslogtreecommitdiffstats
path: root/producer.sh
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-08-02 20:45:59 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-08-02 21:14:34 +0800
commit1035560298d8e5ff0cd0ccde433aed624c546604 (patch)
tree1ac5b6e4fecc4d7aed9d908c0547c93d5b3f472b /producer.sh
parent3ffc33b8fe0d52397698f81dbc3086e398d40b43 (diff)
downloadlex-1035560298d8e5ff0cd0ccde433aed624c546604.tar.gz
Change Unix fifo to a spool file.
Diffstat (limited to 'producer.sh')
-rw-r--r--producer.sh17
1 files changed, 6 insertions, 11 deletions
diff --git a/producer.sh b/producer.sh
index e05dca4..4e9ec41 100644
--- a/producer.sh
+++ b/producer.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-FIFO_PATH="${QUEUE_FIFO_PATH:-/tmp/job_queue}"
+FIFO_PATH="${QUEUE_PATH:-/tmp/job_queue.txt}"
# Validate argument
if [ $# -eq 0 ] || [ -z "$1" ]; then
@@ -11,18 +11,13 @@ fi
MESSAGE="$1"
# Ensure the FIFO exists (create if missing)
-if [ ! -p "$FIFO_PATH" ]; then
- mkfifo -m 0600 "$FIFO_PATH" || {
- echo "[$(date '+%H:%M:%S')] ERROR: Failed to create FIFO at $FIFO_PATH" >&2
- exit 1
- }
-fi
-
-# Handle SIGPIPE gracefully so the producer doesn't crash if the consumer disconnects
-trap '' PIPE
+touch "$FIFO_PATH" 2>/dev/null || {
+ echo "[$(date '+%H:%M:%S')] ERROR: Failed to access queue file at $FIFO_PATH" >&2
+ exit 1
+}
# Publish message to the FIFO
-if echo "$MESSAGE" > "$FIFO_PATH" 2>/dev/null; then
+if echo "$MESSAGE" >> "$FIFO_PATH" 2>/dev/null; then
# Format and cap log line at 72 chars
log_line="[$(date '+%H:%M:%S')] Published: ${MESSAGE}"
if [ ${#log_line} -gt 72 ]; then