add new system_activity.json for rate limit X posts
This commit is contained in:
@@ -16,6 +16,7 @@ from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
SCRIPT_NAME = "foodie_weekly_thread"
|
||||
LOCK_FILE = "/home/shane/foodie_automator/locks/foodie_weekly_thread.lock"
|
||||
LOG_FILE = "/home/shane/foodie_automator/logs/foodie_weekly_thread.log"
|
||||
LOG_PRUNE_DAYS = 30
|
||||
@@ -48,7 +49,7 @@ def setup_logging():
|
||||
with open(LOG_FILE, 'w') as f:
|
||||
f.writelines(pruned_lines)
|
||||
|
||||
logging.basicConfig(
|
||||
logging.basicBasic(
|
||||
filename=LOG_FILE,
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s',
|
||||
@@ -78,7 +79,8 @@ def acquire_lock():
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
"""Handle termination signals gracefully."""
|
||||
logging.info("Received termination signal, exiting...")
|
||||
logging.info("Received termination signal, marking script as stopped...")
|
||||
update_system_activity(SCRIPT_NAME, "stopped") # Added to mark as stopped
|
||||
sys.exit(0)
|
||||
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
@@ -371,10 +373,13 @@ def main():
|
||||
try:
|
||||
lock_fd = acquire_lock()
|
||||
setup_logging()
|
||||
update_system_activity(SCRIPT_NAME, "running", os.getpid()) # Record start
|
||||
post_weekly_thread()
|
||||
update_system_activity(SCRIPT_NAME, "stopped") # Record stop
|
||||
except Exception as e:
|
||||
logging.error(f"Fatal error in main: {e}", exc_info=True)
|
||||
print(f"Fatal error: {e}")
|
||||
update_system_activity(SCRIPT_NAME, "stopped") # Record stop on error
|
||||
sys.exit(1)
|
||||
finally:
|
||||
if lock_fd:
|
||||
|
||||
Reference in New Issue
Block a user