add new system_activity.json for rate limit X posts

This commit is contained in:
2025-05-12 14:24:43 +10:00
parent 765967fb8c
commit 941fe12ec5
6 changed files with 188 additions and 53 deletions
+7 -1
View File
@@ -35,11 +35,14 @@ import fcntl
load_dotenv()
SCRIPT_NAME = "foodie_automator_reddit"
is_posting = False
LOCK_FILE = "/home/shane/foodie_automator/locks/foodie_automator_reddit.lock"
def signal_handler(sig, frame):
logging.info("Received termination signal, checking if safe to exit...")
logging.info("Received termination signal, marking script as stopped...")
update_system_activity(SCRIPT_NAME, "stopped") # Added to mark as stopped
if is_posting:
logging.info("Currently posting, will exit after completion.")
else:
@@ -475,6 +478,7 @@ def run_reddit_automator():
lock_fd = None
try:
lock_fd = acquire_lock()
update_system_activity(SCRIPT_NAME, "running", os.getpid()) # Record start
logging.info("***** Reddit Automator Launched *****")
# Load JSON files once
posted_titles_data = load_json_file(POSTED_TITLES_FILE, EXPIRATION_HOURS)
@@ -485,9 +489,11 @@ def run_reddit_automator():
if not post_data:
logging.info("No postable Reddit article found")
logging.info("Completed Reddit run")
update_system_activity(SCRIPT_NAME, "stopped") # Record stop
return post_data, category, should_continue
except Exception as e:
logging.error(f"Fatal error in run_reddit_automator: {e}", exc_info=True)
update_system_activity(SCRIPT_NAME, "stopped") # Record stop on error
return None, None, False
finally:
if lock_fd: