mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Improving ynh_lxc_stop
This commit is contained in:
parent
0b5b6422e1
commit
f5332971ed
1 changed files with 27 additions and 6 deletions
33
lib/ynh_lxd
33
lib/ynh_lxd
|
@ -128,13 +128,34 @@ ynh_lxc_stop () {
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
# (We also use timeout 30 in front of the command because sometime lxc
|
# If the container exists
|
||||||
# commands can hang forever despite the --timeout >_>...)
|
if ynh_lxc_exists --name=$name
|
||||||
timeout 30 lxc stop --timeout 15 $name 2>/dev/null
|
then
|
||||||
|
ynh_print_info --message="Stopping LXC $name"
|
||||||
|
wait_period=0
|
||||||
|
while ! ynh_lxc_is_stopped --name=$name
|
||||||
|
do
|
||||||
|
lxc stop $name
|
||||||
|
wait_period=$(($wait_period+10))
|
||||||
|
if [ $wait_period -gt 30 ];then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# If the command times out, then add the option --force
|
# If the command times out, then add the option --force
|
||||||
if [ $? -eq 124 ]; then
|
wait_period=0
|
||||||
timeout 30 lxc stop --timeout 15 $name --force 2>/dev/null
|
while ! ynh_lxc_is_stopped --name=$name
|
||||||
|
do
|
||||||
|
lxc stop $name --force
|
||||||
|
wait_period=$(($wait_period+10))
|
||||||
|
if [ $wait_period -gt 30 ];then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue