mirror of
https://github.com/YunoHost/yunohost_demo.git
synced 2024-09-03 19:56:44 +02:00
Time to switch
This commit is contained in:
parent
2776a61252
commit
97847623c3
3 changed files with 17 additions and 3 deletions
|
@ -11,6 +11,7 @@ DOMAIN=demotest1.nohost.me
|
|||
YUNO_PWD=admin
|
||||
LXC_NAME1=yunohost_demo1
|
||||
LXC_NAME2=yunohost_demo2
|
||||
TIME_TO_SWITCH=30 # En minutes
|
||||
|
||||
USER_DEMO=demo
|
||||
PASSWORD_DEMO=demo
|
||||
|
@ -173,3 +174,15 @@ server {
|
|||
EOF
|
||||
|
||||
sudo service nginx reload
|
||||
|
||||
# Mise en place du cron de switch
|
||||
echo | sudo tee /etc/cron.d/demo_switch <<EOF
|
||||
# Switch des conteneurs toutes les $TIME_TO_SWITCH minutes
|
||||
*/$TIME_TO_SWITCH * * * * root $script_dir/demo_switch.sh > /dev/null 2>&1
|
||||
EOF
|
||||
|
||||
# Mise en place de HAProxy
|
||||
# [...]
|
||||
|
||||
# Démarrage de la démo
|
||||
"./$script_dir/demo_start.sh"
|
||||
|
|
|
@ -30,6 +30,5 @@ echo "> Démarrage de la machine"
|
|||
sudo lxc-start -n $LXC_NAME -d
|
||||
sleep 3
|
||||
|
||||
# Vérifie que la machine a démarré:
|
||||
# Vérifie que la machine a démarré
|
||||
sudo lxc-ls -f
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@ if [ "${0:0:1}" == "/" ]; then script_dir="$(dirname "$0")"; else script_dir="$P
|
|||
PLAGE_IP=$(cat "$script_dir/demo_lxc_build.sh" | grep PLAGE_IP= | cut -d '"' -f2)
|
||||
LXC_NAME1=$(cat "$script_dir/demo_lxc_build.sh" | grep LXC_NAME1= | cut -d '"' -f2)
|
||||
LXC_NAME2=$(cat "$script_dir/demo_lxc_build.sh" | grep LXC_NAME2= | cut -d '"' -f2)
|
||||
TIME_TO_SWITCH=$(cat "$script_dir/demo_lxc_build.sh" | grep TIME_TO_SWITCH= | cut -d '"' -f2)
|
||||
|
||||
UPGRADE_DEMO_CONTAINER () { # Démarrage, upgrade et snapshot
|
||||
MACHINE=$1
|
||||
# Attend que la machine soit éteinte.
|
||||
sudo lxc-wait -n $MACHINE -s STOPPED #-t 2000 (Timeout à 33 minutes, puisque le swith est à 30 minutes)
|
||||
TIME_OUT=$(($TIME_TO_SWITCH * 60 + 300)) # Timeout à $TIME_TO_SWITCH +5 minutes, en seconde
|
||||
sudo lxc-wait -n $MACHINE -s 'STOPPED' -t $TIME_OUT
|
||||
|
||||
# Restaure le snapshot
|
||||
sudo lxc-snapshot -r snap0 $MACHINE
|
||||
|
|
Loading…
Reference in a new issue