Skip to content

Commit

Permalink
Allows support for 4k display by increasing shared memory in viewer (#…
Browse files Browse the repository at this point in the history
…1894)

* fix: increase `shm_size` of the viewer service for RPi OS and Balena versions
* modify the docs to include usage of the `--shm-size` flag
  • Loading branch information
nicomiguelino authored May 15, 2024
1 parent 2efa555 commit dc1f963
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
run: |
echo "GIT_SHORT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "BOARD=${{ matrix.board }}" >> $GITHUB_ENV
echo "SHM_SIZE=256mb" >> $GITHUB_ENV
- name: Prepare Balena file
run: |
Expand Down Expand Up @@ -109,4 +110,4 @@ jobs:
with:
balena_token: ${{ secrets.BALENA_TOKEN }}
fleet: screenly_ose/anthias-${{ matrix.board }}
source: balena-deploy
source: balena-deploy
12 changes: 12 additions & 0 deletions bin/deploy_to_balena.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ print_help() {
echo " -f, --fleet FLEET specify the fleet name to deploy to"
echo " -s, --short-hash HASH specify the short hash to use for the image tag"
echo " -d, --dev run in dev mode"
echo " --shm-size SIZE specify the size of the /dev/shm partition, e.g. 256mb, 65536kb, 1gb"
}

while [[ $# -gt 0 ]]; do
Expand Down Expand Up @@ -47,6 +48,11 @@ while [[ $# -gt 0 ]]; do
export DEV_MODE=1
shift
;;
--shm-size)
export SHM_SIZE="$2"
shift
shift
;;
*)
echo "Unknown option $key"
print_help
Expand All @@ -68,6 +74,12 @@ if [[ -z "${FLEET+x}" ]]; then
fi

export GIT_SHORT_HASH=${GIT_SHORT_HASH:-latest}
export DEFAULT_SHM_SIZE='256mb'

if [[ -z "${SHM_SIZE+x}" ]]; then
echo "Using default /dev/shm size of $DEFAULT_SHM_SIZE for the viewer service"
export SHM_SIZE=$DEFAULT_SHM_SIZE
fi

function prepare_balena_file() {
mkdir -p balena-deploy
Expand Down
1 change: 1 addition & 0 deletions bin/upgrade_containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
export MY_IP=$(ip -4 route get 8.8.8.8 | awk {'print $7'} | tr -d '\n')
TOTAL_MEMORY_KB=$(grep MemTotal /proc/meminfo | awk {'print $2'})
export VIEWER_MEMORY_LIMIT_KB=$(echo "$TOTAL_MEMORY_KB" \* 0.8 | bc)
export SHM_SIZE_KB="$(echo "$TOTAL_MEMORY_KB" \* 0.3 | bc | cut -d'.' -f1)"

# Hard code this to latest for now.
export DOCKER_TAG="latest"
Expand Down
1 change: 1 addition & 0 deletions docker-compose.balena.dev.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ services:
- "host.docker.internal:host-gateway"
privileged: true
restart: always
shm_size: ${SHM_SIZE}
volumes:
- resin-data:/data
labels:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.balena.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ services:
- "host.docker.internal:host-gateway"
privileged: true
restart: always
shm_size: ${SHM_SIZE}
volumes:
- resin-data:/data
labels:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ services:
- "host.docker.internal:host-gateway"
privileged: true
restart: always
shm_size: ${SHM_SIZE_KB}kb
volumes:
- resin-data:/data
- /home/${USER}/.screenly:/data/.screenly
Expand Down
10 changes: 10 additions & 0 deletions docs/balena-fleet-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ $ ./bin/deploy_to_balena.sh \
--dev
```

You can also includa a `--shm-size` flag to specify the shared memory size, which defaults
to `256mb`. For example:

```bash
$ ./bin/deploy_to_balena.sh \
--board $BOARD_TYPE \
--fleet $FLEET_NAME \
--shm-size 512mb
```

It would take a while for the deployment to finish. Once it's done, you should
see the new release in the fleet's summary page. You can now add your devices to
the fleet and they should be able to download the new release.
Expand Down

0 comments on commit dc1f963

Please sign in to comment.