mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Adding some timeout because idk lxc command got stuck forever...
This commit is contained in:
parent
0bb042552f
commit
9879774322
1 changed files with 7 additions and 5 deletions
12
lib/lxc.sh
12
lib/lxc.sh
|
@ -41,7 +41,7 @@ CREATE_LXC_SNAPSHOT () {
|
|||
lxc exec $LXC_NAME -- bash -c 'for swapfile in $(ls /swap_* 2>/dev/null); do swapoff $swapfile; done'
|
||||
lxc exec $LXC_NAME -- bash -c 'for swapfile in $(ls /swap_* 2>/dev/null); do rm -f $swapfile; done'
|
||||
|
||||
lxc stop --timeout 15 $LXC_NAME 2>/dev/null
|
||||
timeout 30 lxc stop --timeout 15 $LXC_NAME 2>/dev/null
|
||||
|
||||
# Check if the snapshot already exist
|
||||
if ! LXC_SNAPSHOT_EXISTS "$snapname"
|
||||
|
@ -58,7 +58,7 @@ CREATE_LXC_SNAPSHOT () {
|
|||
LOAD_LXC_SNAPSHOT () {
|
||||
local snapname=$1
|
||||
log_debug "Loading snapshot $snapname ..."
|
||||
lxc stop --timeout 15 $LXC_NAME 2>/dev/null
|
||||
timeout 30 lxc stop --timeout 15 $LXC_NAME 2>/dev/null
|
||||
lxc restore $LXC_NAME $snapname
|
||||
lxc start $LXC_NAME
|
||||
_LXC_START_AND_WAIT $LXC_NAME
|
||||
|
@ -88,11 +88,13 @@ LXC_START () {
|
|||
}
|
||||
|
||||
LXC_STOP () {
|
||||
lxc stop --timeout 15 $LXC_NAME 2>/dev/null
|
||||
# (We also use timeout 30 in front of the command because sometime lxc
|
||||
# commands can hang forever despite the --timeout >_>...)
|
||||
timeout 30 lxc stop --timeout 15 $LXC_NAME 2>/dev/null
|
||||
}
|
||||
|
||||
LXC_RESET () {
|
||||
lxc stop --timeout 15 $LXC_NAME 2>/dev/null
|
||||
timeout 30 lxc stop --timeout 15 $LXC_NAME 2>/dev/null
|
||||
lxc delete $LXC_NAME 2>/dev/null
|
||||
}
|
||||
|
||||
|
@ -101,7 +103,7 @@ _LXC_START_AND_WAIT() {
|
|||
|
||||
restart_container()
|
||||
{
|
||||
lxc stop "$1" --timeout 15 &>/dev/null
|
||||
timeout 30 lxc stop --timeout 15 $1 2>/dev/null
|
||||
lxc start "$1"
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue