diff --git a/ansible/roles/network/tasks/main.yml b/ansible/roles/network/tasks/main.yml index 4b50c71d7..42e438cd5 100644 --- a/ansible/roles/network/tasks/main.yml +++ b/ansible/roles/network/tasks/main.yml @@ -20,8 +20,8 @@ - name: Enable network systemd services ansible.builtin.systemd: name: "{{ item }}" - state: started - enabled: true + state: stopped + enabled: false with_items: "{{ network_systemd_units }}" - name: Disable network manager diff --git a/ansible/roles/screenly/tasks/main.yml b/ansible/roles/screenly/tasks/main.yml index 8c87dc7ee..396b7967b 100644 --- a/ansible/roles/screenly/tasks/main.yml +++ b/ansible/roles/screenly/tasks/main.yml @@ -101,7 +101,7 @@ - name: Enable screenly systemd services ansible.builtin.systemd: name: "{{ item }}" - state: started + state: stopped enabled: true with_items: "{{ screenly_systemd_units }}" diff --git a/ansible/roles/system/tasks/main.yml b/ansible/roles/system/tasks/main.yml index 7434f162b..fa5a1b52b 100644 --- a/ansible/roles/system/tasks/main.yml +++ b/ansible/roles/system/tasks/main.yml @@ -231,7 +231,6 @@ - name: Remove deprecated apt dependencies ansible.builtin.apt: name: - - dphys-swapfile - lightdm - lightdm-gtk-greeter - matchbox @@ -246,60 +245,6 @@ - xserver-xorg state: absent -- name: Make sure distro package of Docker is absent - ansible.builtin.apt: - name: - - docker - - docker-engine - - docker.io - - containerd - - runc - - docker-compose - state: absent - -- name: Add Docker apt key (x86) - ansible.builtin.apt_key: - url: https://download.docker.com/linux/debian/gpg - state: present - when: ansible_architecture == "x86_64" - -- name: Add Docker apt key (Raspberry Pi) - ansible.builtin.apt_key: - url: https://download.docker.com/linux/raspbian/gpg - state: present - when: | - ansible_architecture == "aarch64" or - ansible_architecture == "armv7l" or - ansible_architecture == "armv6l" - -- name: Get Debian name - ansible.builtin.command: lsb_release -cs - register: debian_name - changed_when: false - -- name: Set architecture - ansible.builtin.set_fact: - architecture: "{{ 'amd64' if ansible_architecture == 'x86_64' else 'armhf' }}" - -- name: Add Docker repo - ansible.builtin.lineinfile: - path: /etc/apt/sources.list.d/docker.list - create: true - line: "deb [arch={{ architecture }}] https://download.docker.com/linux/debian {{ debian_name.stdout }} stable" - state: present - owner: root - group: root - mode: "0644" - -- name: Install Docker - ansible.builtin.apt: - name: - - docker-ce:{{ architecture }} - - docker-ce-cli:{{ architecture }} - - docker-compose-plugin:{{ architecture }} - update_cache: true - install_recommends: false - - name: Add user to Docker group (all platforms) ansible.builtin.user: name: "{{ lookup('env', 'USER') }}" @@ -377,11 +322,3 @@ mode: "0644" owner: root group: root - -- name: Disable swap - ansible.builtin.command: /sbin/swapoff --all removes=/var/swap - -- name: Remove swapfile from disk - ansible.builtin.file: - path: /var/swap - state: absent diff --git a/bin/install.sh b/bin/install.sh index 2e860cc57..7b4708715 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -184,9 +184,6 @@ function install_ansible() { function run_ansible_playbook() { display_section "Run the Anthias Ansible Playbook" - sudo -u ${USER} ${SUDO_ARGS[@]} ansible localhost \ - -m git \ - -a "repo=$REPOSITORY dest=${ANTHIAS_REPO_DIR} version=${BRANCH} force=yes" cd ${ANTHIAS_REPO_DIR}/ansible if [ "$ARCHITECTURE" == "x86_64" ]; then @@ -200,10 +197,6 @@ function run_ansible_playbook() { function upgrade_docker_containers() { display_section "Initialize/Upgrade Docker Containers" - wget -q \ - "$GITHUB_RAW_URL/master/bin/upgrade_containers.sh" \ - -O "$UPGRADE_SCRIPT_PATH" - sudo -u ${USER} \ DOCKER_TAG="${DOCKER_TAG}" \ "${UPGRADE_SCRIPT_PATH}" @@ -212,6 +205,8 @@ function upgrade_docker_containers() { function cleanup() { display_section "Clean Up Unused Packages and Files" + sudo -E docker compose -f /home/${USER}/screenly/docker-compose.yml down + sudo apt-get autoclean sudo apt-get clean sudo docker system prune -f diff --git a/bin/upgrade_containers.sh b/bin/upgrade_containers.sh index 94103502d..57396be48 100755 --- a/bin/upgrade_containers.sh +++ b/bin/upgrade_containers.sh @@ -6,8 +6,8 @@ # Export various environment variables 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)" +export VIEWER_MEMORY_LIMIT_KB=$(echo "$TOTAL_MEMORY_KB" \* 0.6 | bc) +export SHM_SIZE_KB="$(echo "$TOTAL_MEMORY_KB" \* 0.25 | bc | cut -d'.' -f1)" export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) @@ -26,7 +26,8 @@ elif grep -qF "Raspberry Pi 2" /proc/device-tree/model; then export DEVICE_TYPE="pi2" else # If all else fail, assume pi1 - export DEVICE_TYPE="pi1" + # TODO: If Raspberry Pi Zero, set DEVICE_TYPE to "pi3." + export DEVICE_TYPE="pi3" # TODO: Revert to "pi1" fi if [[ -n $(docker ps | grep srly-ose) ]]; then diff --git a/docker-compose.yml.tmpl b/docker-compose.yml.tmpl index 6bfdd7e61..82f91b47f 100644 --- a/docker-compose.yml.tmpl +++ b/docker-compose.yml.tmpl @@ -1,30 +1,21 @@ # vim: ft=yaml.docker-compose services: - anthias-wifi-connect: - image: screenly/anthias-wifi-connect:${DOCKER_TAG}-${DEVICE_TYPE} - build: - context: . - dockerfile: docker/Dockerfile.wifi-connect - depends_on: - - anthias-viewer - environment: - PORTAL_LISTENING_PORT: 8000 - CHECK_CONN_FREQ: 10 - PORTAL_SSID: 'Anthias WiFi Connect' - DBUS_SYSTEM_BUS_ADDRESS: 'unix:path=/run/dbus/system_bus_socket' - network_mode: host - privileged: true - volumes: - - type: bind - source: /run/dbus/system_bus_socket - target: /run/dbus/system_bus_socket - anthias-server: image: screenly/anthias-server:${DOCKER_TAG}-${DEVICE_TYPE} build: context: . dockerfile: docker/Dockerfile.server + cpus: "0.25" + cpuset: "1" + blkio_config: + weight: 300 + device_read_bps: + - path: /dev/mmcblk0 + rate: '5mb' + device_write_bps: + - path: /dev/mmcblk0 + rate: '1024k' environment: - MY_IP=${MY_IP} - HOST_USER=${USER} @@ -50,6 +41,16 @@ services: build: context: . dockerfile: docker/Dockerfile.viewer + cpus: "0.5" + cpuset: "1" + blkio_config: + weight: 300 + device_read_bps: + - path: /dev/mmcblk0 + rate: '5mb' + device_write_bps: + - path: /dev/mmcblk0 + rate: '1024k' mem_limit: ${VIEWER_MEMORY_LIMIT_KB}k depends_on: - anthias-server @@ -77,6 +78,16 @@ services: build: context: . dockerfile: docker/Dockerfile.websocket + cpus: "0.25" + cpuset: "1" + blkio_config: + weight: 300 + device_read_bps: + - path: /dev/mmcblk0 + rate: '5mb' + device_write_bps: + - path: /dev/mmcblk0 + rate: '1024k' depends_on: - anthias-server environment: @@ -95,6 +106,16 @@ services: build: context: . dockerfile: docker/Dockerfile.celery + cpus: "0.25" + cpuset: "1" + blkio_config: + weight: 300 + device_read_bps: + - path: /dev/mmcblk0 + rate: '5mb' + device_write_bps: + - path: /dev/mmcblk0 + rate: '1024k' depends_on: - anthias-server - redis @@ -119,6 +140,16 @@ services: build: context: . dockerfile: docker/Dockerfile.redis + cpus: "0.25" + cpuset: "1" + blkio_config: + weight: 300 + device_read_bps: + - path: /dev/mmcblk0 + rate: '5mb' + device_write_bps: + - path: /dev/mmcblk0 + rate: '1024k' ports: - 127.0.0.1:6379:6379 restart: always @@ -130,6 +161,16 @@ services: build: context: . dockerfile: docker/Dockerfile.nginx + cpus: "0.25" + cpuset: "1" + blkio_config: + weight: 300 + device_read_bps: + - path: /dev/mmcblk0 + rate: '5mb' + device_write_bps: + - path: /dev/mmcblk0 + rate: '1024k' ports: - 80:80 environment: