Jemalloc for mariadb (#1200)

* Jemalloc for mariadb

* Update mariadb/rootfs/etc/services.d/mariadb/run

Co-Authored-By: Franck Nijhof <git@frenck.dev>

* Add changelog

* Fix changelog

* Fix build

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Pascal Vizeli
2020-03-30 15:21:41 +02:00
committed by GitHub
parent ba9ce4623a
commit 52175c7944
9 changed files with 51 additions and 23 deletions

View File

@@ -57,7 +57,6 @@ function stop_docker() {
function install() {
docker pull homeassistant/amd64-hassio-supervisor:dev
docker pull homeassistant/amd64-hassio-cli:dev
}
function cleanup_hass_data() {
@@ -102,7 +101,7 @@ case "$1" in
cleanup_hass_data || true
exit 0;;
*)
echo "Creating development Hass.io environment"
echo "Creating development Supervisor environment"
start_docker
trap "stop_docker" ERR
cleanup_docker || true

6
.vscode/tasks.json vendored
View File

@@ -6,7 +6,7 @@
{
"label": "Start Home Assistant",
"type": "shell",
"command": "/workspaces/test_hassio/addons/local/.devcontainer/start_hassio.sh",
"command": "/workspaces/test_hassio/addons/local/.devcontainer/start_supervisor.sh",
"group": {
"kind": "test",
"isDefault": true,
@@ -19,7 +19,7 @@
},{
"label": "Cleanup stale Home Assistant environment",
"type": "shell",
"command": "/workspaces/test_hassio/addons/local/.devcontainer/start_hassio.sh --cleanup",
"command": "/workspaces/test_hassio/addons/local/.devcontainer/start_supervisor.sh --cleanup",
"group": "test",
"presentation": {
"reveal": "always",
@@ -29,7 +29,7 @@
},{
"label": "Run Home Assistant CLI",
"type": "shell",
"command": "docker run --rm -ti -v /etc/machine-id:/etc/machine-id --network=hassio --add-host hassio:172.30.32.2 homeassistant/amd64-hassio-cli:dev",
"command": "docker exec -ti hassio_cli /usr/bin/cli.sh",
"group": "test",
"presentation": {
"reveal": "always",

View File

@@ -1,6 +1,11 @@
# Changelog
## 2.0
## 2.1.0
- Migrate to S6-Overlay
- Use jemalloc for faster database memory management
## 2.0.0
- Pin add-on to Alpine Linux 3.11
- Redirect MariaDB error log to add-on logs
@@ -15,18 +20,18 @@
- Adds database upgrade process during startup
- Change default configuration username from "hass" to "homeassistant"
## 1.3
## 1.3.0
- Update from bash to bashio
## 1.2
## 1.2.0
- Change the way to migrate data
## 1.1
## 1.1.0
- Fix connection issue with 10.3.13
## 1.0
## 1.0.0
- Update MariaDB to 10.3.13

View File

@@ -1,9 +1,6 @@
ARG BUILD_FROM
FROM $BUILD_FROM
# Add env
ENV LANG C.UTF-8
# Setup base
RUN apk add --no-cache \
mariadb \
@@ -11,8 +8,22 @@ RUN apk add --no-cache \
mariadb-server-utils \
pwgen
# Copy data
COPY data/run.sh /
COPY data/mariadb-server.cnf /etc/my.cnf.d/
# Install jemalloc
WORKDIR /usr/src
ARG JEMALLOC_VERSION
RUN apk add --no-cache --virtual .build-deps \
build-base \
&& curl -L -s https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2 | tar -xjf - -C /usr/src \
&& cd /usr/src/jemalloc-${JEMALLOC_VERSION} \
&& ./configure \
&& make \
&& make install \
&& apk del .build-deps \
&& rm -rf /usr/src/jemalloc-${JEMALLOC_VERSION}
CMD [ "/run.sh" ]
ENV LD_PRELOAD="/usr/local/lib/libjemalloc.so.2"
# Copy data
COPY rootfs /
WORKDIR /

View File

@@ -5,5 +5,8 @@
"armhf": "homeassistant/armhf-base:3.11",
"armv7": "homeassistant/armv7-base:3.11",
"i386": "homeassistant/i386-base:3.11"
},
"args": {
"JEMALLOC_VERSION": "5.2.1"
}
}

View File

@@ -1,12 +1,14 @@
{
"name": "MariaDB",
"version": "2.0",
"version": "2.1.1",
"slug": "mariadb",
"description": "An SQL database server",
"url": "https://github.com/home-assistant/hassio-addons/tree/master/mariadb",
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
"startup": "system",
"boot": "auto",
"init": false,
"timeout": 20,
"services": ["mysql:provide"],
"ports": {
"3306/tcp": null
@@ -26,6 +28,5 @@
"logins": [{ "username": "str", "password": "str" }],
"rights": [{ "username": "str", "database": "str" }]
},
"image": "homeassistant/{arch}-addon-mariadb",
"timeout": 20
"image": "homeassistant/{arch}-addon-mariadb"
}

View File

@@ -0,0 +1,8 @@
#!/usr/bin/execlineb -S0
# ==============================================================================
# Take down the S6 supervision tree when mariadb fails
# ==============================================================================
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }
s6-svscanctl -t /var/run/s6/services

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bashio
set -e
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Start MariaDB service if enabled
# ==============================================================================
MARIADB_DATA=/data/databases
NEW_INSTALL=false