diff --git a/check_process b/check_process index 66c602a..9a476f4 100644 --- a/check_process +++ b/check_process @@ -3,7 +3,7 @@ ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) - path="/" (PATH) + path="/gitlab" (PATH) admin="john" (USER) is_public=1 (PUBLIC|public=1|private=0) password="pass" diff --git a/scripts/_common.sh b/scripts/_common.sh index 13761e2..a39d88f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -117,8 +117,57 @@ setup_source() { then dpkg -i $src_filename || true # This command will fail in lxc env sed -i 's/command \"cat \/etc\/sysctl.conf \/etc\/sysctl.d\/\*.conf | sysctl -e -p -\"/command \"cat \/etc\/sysctl.conf\"/g' $final_path/embedded/cookbooks/package/resources/sysctl.rb - sudo gitlab-ctl reconfigure + dpkg --configure gitlab-ce || true else - dpkg -i $src_filename + dpkg -i $src_filename || true fi; +} + +#================================================= +# WAIT +#================================================= +# This function is inspired by the ynh_systemd_action function +waiting_to_start() { + + echo "Start Waiting" + + log_path="/var/log/gitlab/unicorn/current" + + if [ ! -f "$log_path" ] + then + return 0 + fi + + line_match_new="adopted new unicorn master" + line_match_existing="adopted existing unicorn master" + + clean_check_starting() { + # Stop the execution of tail + kill -s 15 $pid_tail 2>&1 + ynh_secure_remove "$templog" 2>&1 + } + + # 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=$! + local inc=0 + + while ! grep --quiet "${line_match_new}" $templog && ! grep --quiet "${line_match_existing}" $templog + do + # Timeout + if [ $inc -gt 100 ] + then + break + fi + + sleep 1 + echo -n "." >&2 + ((inc++)) + done + + echo "Stop Waiting" + + clean_check_starting } \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index aef2702..bb6fd95 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -108,6 +108,7 @@ sudo gitlab-ctl reconfigure if [ $change_path -eq 1 ] then sudo gitlab-ctl restart + sudo gitlab-ctl restart unicorn fi #================================================= @@ -118,17 +119,8 @@ fi systemctl reload nginx -#Fix for the CI -if sudo grep -qa container=lxc /proc/1/environ; -then - status_code=$(curl -s -o /dev/null -w '%{http_code}' "$domain${path_url%/}") - inc=0 +#================================================= +# WAIT +#================================================= - # Have to wait the time that gitlab reload - while [ $status_code == "502" ] && [ $inc -lt 10 ] - do - sleep 10; - status_code=$(curl -s -o /dev/null -w '%{http_code}' "$domain${path_url%/}") - ((inc++)) - done; -fi; \ No newline at end of file +waiting_to_start \ No newline at end of file diff --git a/scripts/install b/scripts/install index 833a70e..ab4be95 100644 --- a/scripts/install +++ b/scripts/install @@ -22,7 +22,7 @@ source ./_common.sh domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -only_use_ldap=$YNH_APP_ARG_IS_PUBLIC +only_use_ldap=$YNH_APP_ARG_ONLY_USE_LDAP admin=$YNH_APP_ARG_ADMIN #================================================= @@ -134,8 +134,7 @@ fi systemctl reload nginx #================================================= -# SETUP LOGROTATE +# WAIT #================================================= -# Configure logrotate -#ynh_use_logrotate "/var/log/$app" +waiting_to_start \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 045e126..05f6839 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,13 +30,12 @@ portUnicorn=$(ynh_app_setting_get "$app" unicorn_port) # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -# TODO: Backup and Restore Scripts -## Backup the current version of the app -#ynh_backup_before_upgrade -#ynh_clean_setup () { -# # restore it if the upgrade fails -# ynh_restore_upgradebackup -#} +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -96,17 +95,8 @@ fi # Reload nginx service systemctl reload nginx -#Fix for the CI -if sudo grep -qa container=lxc /proc/1/environ; -then - status_code=$(curl -s -o /dev/null -w '%{http_code}' "$domain${path_url%/}") - inc=0 +#================================================= +# WAIT +#================================================= - # Have to wait the time that gitlab reload - while [ $status_code == "502" ] && [ $inc -lt 10 ] - do - sleep 10; - status_code=$(curl -s -o /dev/null -w '%{http_code}' "$domain${path_url%/}") - ((inc++)) - done; -fi; +waiting_to_start \ No newline at end of file