git: 42e0f0390486 - main - www/gitlab: make it possible to define the log level of gitlab

From: Matthias Fechner <mfechner_at_FreeBSD.org>
Date: Sat, 18 Jan 2025 12:35:17 UTC
The branch main has been updated by mfechner:

URL: https://cgit.FreeBSD.org/ports/commit/?id=42e0f039048691107d8e521e7f707b74157bc622

commit 42e0f039048691107d8e521e7f707b74157bc622
Author:     Matthias Fechner <mfechner@FreeBSD.org>
AuthorDate: 2025-01-18 12:00:50 +0000
Commit:     Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2025-01-18 12:33:23 +0000

    www/gitlab: make it possible to define the log level of gitlab
    
    For only warnings, just execute:
    sysrc gitlab_log_level="warn"
    
    and restart gitlab:
    service gitlab restart
    
    Possible values are:
    debug
    info
    warn
    error
---
 www/gitlab/Makefile.common |  2 +-
 www/gitlab/files/gitlab.in | 24 ++++++++++++++----------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/www/gitlab/Makefile.common b/www/gitlab/Makefile.common
index 0e8f4676d38c..710dccddf139 100644
--- a/www/gitlab/Makefile.common
+++ b/www/gitlab/Makefile.common
@@ -1,5 +1,5 @@
 GITLAB_VERSION=		17.8.0
-GITLAB_PORTREVISION=	1
+GITLAB_PORTREVISION=	2
 
 # Git version gitaly should use (from gitlab mirror)
 # Find current tag from Makefile and .gitlab-ci.yaml
diff --git a/www/gitlab/files/gitlab.in b/www/gitlab/files/gitlab.in
index a386086fb70c..b38c8d7c3a11 100644
--- a/www/gitlab/files/gitlab.in
+++ b/www/gitlab/files/gitlab.in
@@ -47,6 +47,8 @@ stop_precmd=${name}_init
 : ${gitlab_allow_conflicts:="NO"}
 : ${gitlab_wait:="120"}
 : ${gitlab_svcj_options:="net_basic"}
+# Use debug, info, warn, error
+: ${gitlab_log_level:="info"}
 
 load_rc_config $name
 
@@ -377,14 +379,14 @@ start_gitlab() {
     # Remove old socket if it exists
     rm -f "$rails_socket" 2>/dev/null
     # Start the web server
-    RAILS_ENV=$RAILS_ENV USE_WEB_SERVER=$use_web_server bin/web start
+    GITLAB_LOG_LEVEL=${gitlab_log_level} RAILS_ENV=$RAILS_ENV USE_WEB_SERVER=$use_web_server bin/web start
   fi
 
   # If sidekiq is already running, don't start it again.
   if [ "$sidekiq_status" = "0" ]; then
     echo "The Sidekiq job dispatcher is already running with pid $spid, not restarting"
   else
-    RAILS_ENV=$RAILS_ENV SIDEKIQ_WORKERS=$SIDEKIQ_WORKERS bin/background_jobs start > /dev/null &
+    GITLAB_LOG_LEVEL=${gitlab_log_level} RAILS_ENV=$RAILS_ENV SIDEKIQ_WORKERS=$SIDEKIQ_WORKERS bin/background_jobs start > /dev/null &
   fi
 
   if [ "$gitlab_workhorse_status" = "0" ]; then
@@ -394,7 +396,7 @@ start_gitlab() {
     # Because gitlab-workhorse has multiple executables we need to fix
     # the PATH.
     $app_root/bin/daemon_with_pidfile $gitlab_workhorse_pid_path  \
-      /usr/bin/env PATH=$gitlab_workhorse_dir:$PATH \
+      /usr/bin/env PATH=$gitlab_workhorse_dir:$PATH GITLAB_LOG_LEVEL=${gitlab_log_level} \
       gitlab-workhorse $gitlab_workhorse_options \
       >> $gitlab_workhorse_log 2>&1 &
   fi
@@ -404,7 +406,7 @@ start_gitlab() {
     if [ "$mail_room_status" = "0" ]; then
       echo "The MailRoom email processor is already running with pid $mpid, not restarting"
     else
-      RAILS_ENV=$RAILS_ENV bin/mail_room start &
+      GITLAB_LOG_LEVEL=${gitlab_log_level} RAILS_ENV=$RAILS_ENV bin/mail_room start &
     fi
   fi
 
@@ -413,6 +415,7 @@ start_gitlab() {
       echo "The GitLab Pages is already running with pid $gppid, not restarting"
     else
       $app_root/bin/daemon_with_pidfile $gitlab_pages_pid_path  \
+        /usr/bin/env GITLAB_LOG_LEVEL=${gitlab_log_level} \
         $gitlab_pages_dir/gitlab-pages $gitlab_pages_options \
         >> $gitlab_pages_log 2>&1 &
     fi
@@ -423,6 +426,7 @@ start_gitlab() {
       echo "Gitaly is already running with pid $gapid, not restarting"
     else
       $app_root/bin/daemon_with_pidfile $gitaly_pid_path \
+        /usr/bin/env GITLAB_LOG_LEVEL=${gitlab_log_level} \
         $gitaly_dir/bin/gitaly $gitaly_dir/config.toml >> $gitaly_log 2>&1 &
     fi
   fi
@@ -439,11 +443,11 @@ stop_gitlab() {
 
   if [ "$web_status" = "0" ]; then
     echo "Shutting down GitLab web server"
-    RAILS_ENV=$RAILS_ENV USE_WEB_SERVER=$use_web_server bin/web stop
+    GITLAB_LOG_LEVEL=${gitlab_log_level} RAILS_ENV=$RAILS_ENV USE_WEB_SERVER=$use_web_server bin/web stop
   fi
   if [ "$sidekiq_status" = "0" ]; then
     echo "Shutting down GitLab Sidekiq"
-    RAILS_ENV=$RAILS_ENV SIDEKIQ_WORKERS=$SIDEKIQ_WORKERS bin/background_jobs stop
+    GITLAB_LOG_LEVEL=${gitlab_log_level} RAILS_ENV=$RAILS_ENV SIDEKIQ_WORKERS=$SIDEKIQ_WORKERS bin/background_jobs stop
   fi
   if [ "$gitlab_workhorse_status" = "0" ]; then
     echo "Shutting down GitLab Workhorse"
@@ -451,7 +455,7 @@ stop_gitlab() {
   fi
   if [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; then
     echo "Shutting down GitLab MailRoom"
-    RAILS_ENV=$RAILS_ENV bin/mail_room stop
+    GITLAB_LOG_LEVEL=${gitlab_log_level} RAILS_ENV=$RAILS_ENV bin/mail_room stop
   fi
   if [ "$gitlab_pages_status" = "0" ]; then
     echo "Shutting down gitlab-pages"
@@ -543,15 +547,15 @@ reload_gitlab(){
     exit 1
   fi
   printf "Reloading GitLab web server configuration... "
-  RAILS_ENV=$RAILS_ENV USE_WEB_SERVER=$use_web_server bin/web reload
+  GITLAB_LOG_LEVEL=${gitlab_log_level} RAILS_ENV=$RAILS_ENV USE_WEB_SERVER=$use_web_server bin/web reload
   echo "Done."
 
   echo "Restarting GitLab Sidekiq since it isn't capable of reloading its config..."
-  RAILS_ENV=$RAILS_ENV SIDEKIQ_WORKERS=$SIDEKIQ_WORKERS bin/background_jobs restart & /dev/null &
+  GITLAB_LOG_LEVEL=${gitlab_log_level} RAILS_ENV=$RAILS_ENV SIDEKIQ_WORKERS=$SIDEKIQ_WORKERS bin/background_jobs restart & /dev/null &
 
   if [ "$mail_room_enabled" != true ]; then
     echo "Restarting GitLab MailRoom since it isn't capable of reloading its config..."
-    RAILS_ENV=$RAILS_ENV bin/mail_room restart
+    GITLAB_LOG_LEVEL=${gitlab_log_level} RAILS_ENV=$RAILS_ENV bin/mail_room restart
   fi
 
   wait_for_pids