mirror of
https://github.com/YunoHost-Apps/gitlab_ynh.git
synced 2024-09-03 18:36:35 +02:00
wait after install, upgrade and change url
This commit is contained in:
parent
32dca96b10
commit
ac3f7679c3
5 changed files with 70 additions and 40 deletions
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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;
|
||||
waiting_to_start
|
|
@ -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
|
|
@ -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
|
Loading…
Add table
Reference in a new issue