airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] phani8996 commented on a change in pull request #3992: [AIRFLOW-620] Feature to tail custom number of logs instead of rendering whole log
Date Fri, 12 Oct 2018 08:00:41 GMT
phani8996 commented on a change in pull request #3992: [AIRFLOW-620] Feature to tail custom
number of logs instead of rendering whole log
URL: https://github.com/apache/incubator-airflow/pull/3992#discussion_r224701122
 
 

 ##########
 File path: airflow/bin/cli.py
 ##########
 @@ -1023,17 +1023,39 @@ def scheduler(args):
 @cli_utils.action_logging
 def serve_logs(args):
     print("Starting flask")
-    import flask
-    flask_app = flask.Flask(__name__)
+    from flask import Flask, request, Response, stream_with_context, send_from_directory
+    flask_app = Flask(__name__)
 
     @flask_app.route('/log/<path:filename>')
     def serve_logs(filename):  # noqa
+        def tail_logs(logdir, filename, num_lines):
+            logpath = "{logdir}/{filename}".format(logdir=logdir, filename=filename)
+            logsize = os.path.getsize(logpath)
+            if logsize >= 100 * 1024 * 1024:
+                p1 = subprocess.Popen(["tail", "-n " + str(num_lines), filename],
 
 Review comment:
   For bigger log files reading whole file and returning last few lines is impractical. Based
on file size we will rendering by tail or file reading in python

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message