From 3e6bbb7483a25e4c5a8ed8789d51ae33fba78219 Mon Sep 17 00:00:00 2001
From: Marco Malavolti <marco.malavolti@garr.it>
Date: Sun, 6 Aug 2023 12:14:57 +0200
Subject: [PATCH] Added entityID info link & UWSGI log rotation

---
 Dockerfile          | 7 ++++---
 eccs-logrotate.conf | 9 +++++++++
 eccs_cron           | 1 +
 supervisord.conf    | 4 ++--
 web/eccs.js         | 6 +++++-
 5 files changed, 21 insertions(+), 6 deletions(-)
 create mode 100644 eccs-logrotate.conf

diff --git a/Dockerfile b/Dockerfile
index 83402f3..b64a74d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -12,7 +12,7 @@ RUN useradd -rms /bin/bash eccs
 
 RUN apt-get update \
     && apt-get install -y apt-utils net-tools vim cron wget gpg gpg-agent unzip ca-certificates \
-    build-essential python3-dev libxml2-dev libxml2-dev libxslt1-dev \
+    build-essential python3-dev libxml2-dev libxml2-dev libxslt1-dev logrotate \
     apache2 php supervisor uwsgi uwsgi-plugin-python3 libapache2-mod-proxy-uwsgi libxml2-utils \
     python3 python3-pip python3-click python3-flask python3-flask-restful \
     python3-requests python3-selenium python3-urllib3 --no-install-recommends \
@@ -48,8 +48,9 @@ COPY --chown=eccs:eccs  web/ web/
 
 USER root
 
-COPY eccs_cron /etc/cron.d/eccs_cron
-COPY pyff_cron /etc/cron.d/pyff_cron
+COPY eccs-logrotate.conf /etc/logrotate.d/eccs
+COPY eccs_cron /etc/cron.d/eccs
+COPY pyff_cron /etc/cron.d/pyff
 
 # Install ECCS API
 COPY eccs.conf /etc/apache2/conf-available/eccs.conf
diff --git a/eccs-logrotate.conf b/eccs-logrotate.conf
new file mode 100644
index 0000000..2244e9f
--- /dev/null
+++ b/eccs-logrotate.conf
@@ -0,0 +1,9 @@
+/home/eccs/logs/eccs-uwsgi.log {
+    su root root
+    create 664 eccs eccs
+    rotate 30
+    daily
+    nocompress
+    dateext
+    ifempty
+}
diff --git a/eccs_cron b/eccs_cron
index de497c5..cf674b4 100644
--- a/eccs_cron
+++ b/eccs_cron
@@ -1,3 +1,4 @@
+0 0 * * * /usr/sbin/logrotate /etc/logrotate.d/eccs
 0 3 * * * /usr/bin/touch /home/eccs/eccs.ini
 0 4 * * * /bin/bash /home/eccs/cleanAndRunEccs.sh > /home/eccs/logs/eccs-cron.log 2>&1
 0 10 * * * /bin/bash /home/eccs/clean7daysOldFiles.sh > /home/eccs/logs/eccs-clean.log 2>&1
diff --git a/supervisord.conf b/supervisord.conf
index d1deab0..c14b159 100644
--- a/supervisord.conf
+++ b/supervisord.conf
@@ -29,9 +29,9 @@ autorestart=true
 [program:uwsgi]
 #command=uwsgi --ini /root/eccs/eccs.ini --die-on-term
 command=uwsgi --ini /home/eccs/eccs.ini
-stdout_logfile=/dev/stdout
+stdout_logfile=/home/eccs/logs/eccs-uwsgi.log
 stdout_logfile_maxbytes=0
-stderr_logfile=/dev/stderr
+stderr_logfile=/home/eccs/logs/eccs-uwsgi.log
 stderr_logfile_maxbytes=0
 autostart=true
 autorestart=true
diff --git a/web/eccs.js b/web/eccs.js
index 1bf3d29..9391133 100644
--- a/web/eccs.js
+++ b/web/eccs.js
@@ -312,7 +312,11 @@ $(document).ready(function() {
               "data": "displayName",
               "defaultContent": ''
             },
-            { "data": "entityID" },
+            { "data": "entityID",
+              "render": function(data, type, row, meta) {
+                 return '<a target="_blank" href="https://technical.edugain.org/api.php?action=show_entity_details&format=html&opt=standalone&e_id=' + data + '">' + data + '</a>';
+              }
+	    },
             { "data": "registrationAuthority" },
             { 
               "data": "date",
-- 
GitLab