-
-
import sys import time import datetime import os import re def read_log(f): while True: logfile = os.popen(f) while True: new_line = logfile.readline() if new_line: yield new_line else: time.sleep(1) logfile.close() break def find_place_order(line): match = re.search("shangpin!saveSp.action", line) if match: print("place order.") return True return False def monitor(filename): log = read_log(filename) for line in log: if find_place_order(line): # The event is triggered print("-- The event is triggered") monitor("docker logs -f --tail=0 iios-nginx")
-