add_logging.py 613 B

1234567891011121314151617181920
  1. import os
  2. files_to_update = ['scripts/setup_deploy.py', 'docker-compose.yml', 'docker/zabbix/docker-compose.yml']
  3. log_config = '''restart: always
  4. logging:
  5. driver: "json-file"
  6. options:
  7. max-size: "50m"
  8. max-file: "3"'''
  9. for file_path in files_to_update:
  10. if not os.path.exists(file_path):
  11. continue
  12. with open(file_path, 'r', encoding='utf-8') as f:
  13. content = f.read()
  14. if 'logging:' not in content:
  15. content = content.replace('restart: always', log_config)
  16. with open(file_path, 'w', encoding='utf-8') as f:
  17. f.write(content)