add new system_activity.json for rate limit X posts
This commit is contained in:
@@ -14,6 +14,7 @@ from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
SCRIPT_NAME = "foodie_engagement_tweet"
|
||||
LOCK_FILE = "/home/shane/foodie_automator/locks/foodie_engagement_tweet.lock"
|
||||
LOG_FILE = "/home/shane/foodie_automator/logs/foodie_engagement_tweet.log"
|
||||
LOG_PRUNE_DAYS = 30
|
||||
@@ -76,7 +77,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")
|
||||
sys.exit(0)
|
||||
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
@@ -193,10 +195,14 @@ def main():
|
||||
try:
|
||||
lock_fd = acquire_lock()
|
||||
setup_logging()
|
||||
update_system_activity(SCRIPT_NAME, "running", os.getpid()) # Record start
|
||||
post_engagement_tweet()
|
||||
update_system_activity(SCRIPT_NAME, "stopped") # Record stop
|
||||
sys.exit(0)
|
||||
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