mirror of
https://github.com/YunoHost-Apps/gitlab_ynh.git
synced 2024-09-03 18:36:35 +02:00
commit
970e8feeaf
6 changed files with 45 additions and 74 deletions
|
@ -113,62 +113,6 @@ ynh_systemd_action() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function is inspired by the ynh_systemd_action function
|
|
||||||
|
|
||||||
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
|
||||||
#
|
|
||||||
# usage: gitlab_ctl_waiting [ [-t timeout] ]
|
|
||||||
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
|
||||||
gitlab_ctl_waiting() {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
declare -Ar args_array=( [t]=timeout= )
|
|
||||||
local timeout
|
|
||||||
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
|
|
||||||
local line_match_new="adopted new unicorn master"
|
|
||||||
local line_match_existing="adopted existing unicorn master"
|
|
||||||
local line_match_error="master failed to start"
|
|
||||||
local log_path="/var/log/gitlab/unicorn/current"
|
|
||||||
|
|
||||||
local timeout=${timeout:-300}
|
|
||||||
|
|
||||||
# Following the starting of the app in its log
|
|
||||||
local templog="$(mktemp)"
|
|
||||||
tail -F -n1 "$log_path" >"$templog" &
|
|
||||||
# get the PID of the tail command
|
|
||||||
local pid_tail=$!
|
|
||||||
|
|
||||||
if grep --quiet "${line_match_error}" $templog; then # error, so restart gitlab
|
|
||||||
gitlab-ctl restart
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Start the timeout and try to find line_match_new or line_match_existing
|
|
||||||
local i=0
|
|
||||||
for i in $(seq 1 $timeout)
|
|
||||||
do
|
|
||||||
if grep --quiet "${line_match_new}" "$templog" || grep --quiet "${line_match_existing}" "$templog"; then
|
|
||||||
ynh_print_info --message="Gitlab has correctly started."
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if [ $i -ge 3 ]; then
|
|
||||||
echo -n "." >&2
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
if [ $i -ge 3 ]; then
|
|
||||||
echo "" >&2
|
|
||||||
fi
|
|
||||||
if [ $i -eq $timeout ]
|
|
||||||
then
|
|
||||||
ynh_print_warn --message="Gitlab didn't fully started before the timeout."
|
|
||||||
ynh_print_warn --message="Please find here an extract of the end of the log of Gitlab:"
|
|
||||||
test -e "$log_path" && echo "--" >&2 && tail --lines=$length "$log_path" >&2
|
|
||||||
fi
|
|
||||||
ynh_clean_check_starting
|
|
||||||
}
|
|
||||||
|
|
||||||
# Clean temporary process and file used by ynh_check_starting
|
# Clean temporary process and file used by ynh_check_starting
|
||||||
# (usually used in ynh_clean_setup scripts)
|
# (usually used in ynh_clean_setup scripts)
|
||||||
#
|
#
|
||||||
|
|
|
@ -125,9 +125,13 @@ if [ $change_path -eq 1 ]; then
|
||||||
gitlab-ctl restart unicorn
|
gitlab-ctl restart unicorn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# WAITING GITLAB
|
||||||
|
#=================================================
|
||||||
ynh_print_info "Waiting for gitlab..."
|
ynh_print_info "Waiting for gitlab..."
|
||||||
|
|
||||||
gitlab_ctl_waiting --timeout=3600
|
# Action status to just wait the service
|
||||||
|
ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
|
|
|
@ -182,6 +182,12 @@ gitlab-ctl reconfigure
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log /var/log/$app/gitlab-rails/api_json.log /var/log/$app/gitlab-rails/production.log /var/log/$app/gitlab-rails/production_json.log /var/log/$app/gitlab-rails/sidekiq.log /var/log/$app/unicorn/unicorn_stderr.log /var/log/$app/unicorn/current /var/log/$app/alertmanager/current /var/log/$app/gitaly/current /var/log/$app/gitlab-monitor/current /var/log/$app/gitlab-shell/gitlab-shell.log /var/log/$app/gitlab-workhorse/current /var/log/$app/logrotate/current /var/log/$app/nginx/current /var/log/$app/nginx/access.log /var/log/$app/nginx/error.log /var/log/$app/nginx/gitlab_access.log /var/log/$app/nginx/gitlab_error.log /var/log/$app/node-exporter/current /var/log/$app/postgres-exporter/current /var/log/$app/postgresql/current /var/log/$app/prometheus/current /var/log/$app/redis/current /var/log/$app/redis-exporter/current"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -193,13 +199,6 @@ if [ $is_public -eq 1 ]; then
|
||||||
ynh_app_setting_set $app unprotected_uris "/"
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTART GITLAB
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info "Waiting for gitlab..."
|
|
||||||
|
|
||||||
gitlab_ctl_waiting --timeout=3600
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -24,6 +24,16 @@ config_path=$(ynh_app_setting_get $app config_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
#=================================================
|
||||||
|
# REMOVE SERVICE FROM ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if yunohost service status "gitlab-runsvdir" >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
ynh_print_info "Removing $app service"
|
||||||
|
yunohost service remove "gitlab-runsvdir"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP GITLAB
|
# STOP GITLAB
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -86,7 +96,7 @@ fi
|
||||||
ynh_secure_remove "/var/opt/$app"
|
ynh_secure_remove "/var/opt/$app"
|
||||||
|
|
||||||
# Remove the log files
|
# Remove the log files
|
||||||
ynh_secure_remove "/var/log/$app/"
|
ynh_secure_remove "/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -122,14 +122,21 @@ ynh_exec_warn_less gitlab-rake gitlab:backup:restore force=yes BACKUP=$last_back
|
||||||
|
|
||||||
gitlab-rake gitlab:check SANITIZE=true
|
gitlab-rake gitlab:check SANITIZE=true
|
||||||
|
|
||||||
gitlab-ctl restart
|
|
||||||
|
|
||||||
ynh_print_info "Waiting for gitlab..."
|
|
||||||
|
|
||||||
gitlab_ctl_waiting --timeout=3600
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log /var/log/$app/gitlab-rails/api_json.log /var/log/$app/gitlab-rails/production.log /var/log/$app/gitlab-rails/production_json.log /var/log/$app/gitlab-rails/sidekiq.log /var/log/$app/unicorn/unicorn_stderr.log /var/log/$app/unicorn/current /var/log/$app/alertmanager/current /var/log/$app/gitaly/current /var/log/$app/gitlab-monitor/current /var/log/$app/gitlab-shell/gitlab-shell.log /var/log/$app/gitlab-workhorse/current /var/log/$app/logrotate/current /var/log/$app/nginx/current /var/log/$app/nginx/access.log /var/log/$app/nginx/error.log /var/log/$app/nginx/gitlab_access.log /var/log/$app/nginx/gitlab_error.log /var/log/$app/node-exporter/current /var/log/$app/postgres-exporter/current /var/log/$app/postgresql/current /var/log/$app/prometheus/current /var/log/$app/redis/current /var/log/$app/redis-exporter/current"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# WAITING GITLAB
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info "Waiting for gitlab..."
|
||||||
|
|
||||||
|
ynh_systemd_action --action=restart --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -197,22 +197,29 @@ ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
yunohost service add "gitlab-runsvdir" --log "/var/log/$app/gitlab-rails/application.log /var/log/$app/gitlab-rails/api_json.log /var/log/$app/gitlab-rails/production.log /var/log/$app/gitlab-rails/production_json.log /var/log/$app/gitlab-rails/sidekiq.log /var/log/$app/unicorn/unicorn_stderr.log /var/log/$app/unicorn/current /var/log/$app/alertmanager/current /var/log/$app/gitaly/current /var/log/$app/gitlab-monitor/current /var/log/$app/gitlab-shell/gitlab-shell.log /var/log/$app/gitlab-workhorse/current /var/log/$app/logrotate/current /var/log/$app/nginx/current /var/log/$app/nginx/access.log /var/log/$app/nginx/error.log /var/log/$app/nginx/gitlab_access.log /var/log/$app/nginx/gitlab_error.log /var/log/$app/node-exporter/current /var/log/$app/postgres-exporter/current /var/log/$app/postgresql/current /var/log/$app/prometheus/current /var/log/$app/redis/current /var/log/$app/redis-exporter/current"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
# If app is public, add url to SSOWat conf as skipped_uris
|
||||||
if [[ $is_public -eq 1 ]]; then
|
if [ $is_public -eq 1 ]; then
|
||||||
# See install script
|
# See install script
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTART GITLAB
|
# WAITING GITLAB
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Waiting for gitlab..."
|
ynh_print_info "Waiting for gitlab..."
|
||||||
|
|
||||||
gitlab_ctl_waiting --timeout=3600
|
# Action status to just wait the service
|
||||||
|
ynh_systemd_action --action=status --service_name="gitlab-runsvdir" --log_path="/var/log/$app/unicorn/current" --line_match="adopted" --timeout=3600
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
Loading…
Add table
Reference in a new issue