diff options
author | Christophe Lyon <christophe.lyon@linaro.org> | 2017-03-29 20:21:47 +0000 |
---|---|---|
committer | Christophe Lyon <christophe.lyon@linaro.org> | 2017-03-29 20:26:56 +0000 |
commit | 8dd72d26d0a1865bdeacb179fedf96324f22eba3 (patch) | |
tree | 42079cf101b177cb1d307d81a79a8d174b56dcdc | |
parent | 1fb719a1a7a14d8cc104ed0003f0cc843a569516 (diff) |
start-container-docker.sh: Add --memory option.
To control the memory limit of the docker container.
start-container-none.sh, start-container-schroot.sh:
Support, but ignore --memory option. (To keep the
same interface as start-container-docker.sh).
Change-Id: Ie44071eae95103a3ba53b0406e106aa310184116
-rwxr-xr-x | start-container-docker.sh | 11 | ||||
-rwxr-xr-x | start-container-none.sh | 8 | ||||
-rwxr-xr-x | start-container-schroot.sh | 8 |
3 files changed, 23 insertions, 4 deletions
diff --git a/start-container-docker.sh b/start-container-docker.sh index 8d26cffb..b106e80d 100755 --- a/start-container-docker.sh +++ b/start-container-docker.sh @@ -16,7 +16,7 @@ set -e # and returns shell statements to export the related variables. In # this case, it also defines ${SSH_AGENT_CLEANUP}. usage() { - echo "Usage: $0 --arch container-arch --distro flavour [--session-host host] [--session-name name] [--task {build|test}]" + echo "Usage: $0 --arch container-arch --distro flavour [--session-host host] [--session-name name] [--task {build|test}] [--memory XXXX]" echo echo " container-arch: architecture (eg: amd64, i386, arm64, armhf)" echo " distro: distribution (eg: trusty)" @@ -24,6 +24,7 @@ usage() { echo " useful if the name resolution does not work correctly" echo " session-name: session, in case the default '$BUILD_NUMBER-$JOB_NAME' is not suitable" echo " task: type of container (build or test, default=build)" + echo " memory: limit memory usage to XXXX MB, defaults to 7500" exit 1 } @@ -38,6 +39,7 @@ distro= session_host= session_name= task="build" +memory=7500 while [ $# -ge 1 ] do @@ -67,6 +69,11 @@ do [ x${task} = x ] && usage shift 2 ;; + --memory) + memory=$2 + [ x${memory} = x ] && usage + shift 2 + ;; *) echo "Unsupported option: $1" usage @@ -124,7 +131,7 @@ session_id=$($DOCKER run --name $session_name -dtP \ -v $HOME/snapshots-ref:$HOME/snapshots-ref:ro \ -v $WORKSPACE:$WORKSPACE \ ${SECURITY} \ - --memory=7500M --pids-limit=5000 \ + --memory=${memory}M --pids-limit=5000 \ $image) if [ x"$session_id" = x ]; then diff --git a/start-container-none.sh b/start-container-none.sh index 0c55e08e..304f3a4b 100755 --- a/start-container-none.sh +++ b/start-container-none.sh @@ -16,7 +16,7 @@ set -e # - definition of ${session_host} and ${session_port}, can be used for # a remote connexion to the container usage() { - echo "Usage: $0 --arch container-arch --distro flavour [--session-host host] [--session-name name] [--task {build|test}]" + echo "Usage: $0 --arch container-arch --distro flavour [--session-host host] [--session-name name] [--task {build|test}] [--memory XXXX]" echo echo " container-arch: architecture (eg: amd64, i386, arm64, armhf)" echo " distro: distribution (eg: trusty)" @@ -24,6 +24,7 @@ usage() { echo " useful if the name resolution does not work correctly" echo " session-name: session, in case the default '$BUILD_NUMBER-$JOB_NAME' is not suitable" echo " task: type of container (build or test, default=build)" + echo " memory: ignored" exit 1 } @@ -67,6 +68,11 @@ do [ x${task} = x ] && usage shift 2 ;; + --memory) + memory=$2 + [ x${memory} = x ] && usage + shift 2 + ;; *) echo "Unsupported option: $1" usage diff --git a/start-container-schroot.sh b/start-container-schroot.sh index b9bacd88..b9419e0d 100755 --- a/start-container-schroot.sh +++ b/start-container-schroot.sh @@ -13,7 +13,7 @@ set -e # - definition of ${session_host} and ${session_port}, can be used for # a remote connexion to the container usage() { - echo "Usage: $0 --arch container-arch --distro flavour [--session-host host] [--session-name name] [--task {build|test}]" + echo "Usage: $0 --arch container-arch --distro flavour [--session-host host] [--session-name name] [--task {build|test}] [--memory XXXX]" echo echo " container-arch: architecture (eg: amd64, i386, arm64, armhf)" echo " distro: distribution (eg: trusty)" @@ -21,6 +21,7 @@ usage() { echo " useful if the name resolution does not work correctly" echo " session-name: session, in case the default '$BUILD_NUMBER-$JOB_NAME' is not suitable" echo " task: type of container (build or test, default=build)" + echo " memory: ignored" exit 1 } @@ -64,6 +65,11 @@ do [ x${task} = x ] && usage shift 2 ;; + --memory) + memory=$2 + [ x${memory} = x ] && usage + shift 2 + ;; *) echo "Unsupported option: $1" usage |