[toc]web
咱們的airflow部署方式爲分佈式的,在主節點上部署了webserver,worker節點部署了worker和日誌服務器,並無將日誌寫入遠程服務器,因此任務的日誌是直接寫本地磁盤並經過日誌服務器傳輸給webserver進行展現的。在某一次的做業日誌查看中發現出現了中文亂碼問題。json
@flask_app.route('/log/<path:filename>') def serve_logs(filename): # noqa log = os.path.expanduser(conf.get('core', 'BASE_LOG_FOLDER')) return flask.send_from_directory( log, filename, mimetype="application/json", as_attachment=False) WORKER_LOG_SERVER_PORT = \ int(conf.get('celery', 'WORKER_LOG_SERVER_PORT')) flask_app.run( host='0.0.0.0', port=WORKER_LOG_SERVER_PORT)
該代碼中的 flask.send_from_directory 這個方法是傳輸本地文件的給webserver進行日誌展現的flask
修改mimetype爲mimetype="application/json;charset=utf-8",重啓日誌服務器,問題解決瀏覽器
排查過程並不算難,文章寫得很差還請各位童鞋諒解,本次中文問題涉及到了修改源碼的操做,不得不說老外的東西畢竟是老外的東西,他們在用的時候可能沒有這種問題,但願本篇文章對各位有幫助,謝謝!服務器