summaryrefslogtreecommitdiffstats
path: root/producer.sh
diff options
context:
space:
mode:
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