Skip to content

Commit

Permalink
新增shell运行日志
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu0823 committed Jun 19, 2024
1 parent 94e0fee commit 66e9aab
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions docker_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ def handle_event(event, names, valid_events):
if event['status'] in list(event_model.keys()):
logger.debug('捕获事件:', name, event.get('status'), event_model[event["status"]])
handing_event = True
subprocess.run(f'chmod 777 {event_model[event["status"]]}', shell=True)
subprocess.run(f'sh {event_model[event["status"]]}', shell=True)
run_command(f'chmod 777 {event_model[event["status"]]}')
run_command(f'sh {event_model[event["status"]]}')
handing_event = False


def run_command(command):
"""运行命令"""
try:
result = subprocess.run(command, shell=True, capture_output=True, text=True)
logger.debug('Command Output: %s', result.stdout)
if result.stderr:
logger.error("Command Error: %s", result.stderr)
except Exception as e:
logger.error("Command Exception: %s", str(e))

0 comments on commit 66e9aab

Please sign in to comment.