From 6aee89665746f59c7600ee6f0133ad4284b9ddc9 Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Thu, 25 Jan 2024 16:40:28 +0100 Subject: [PATCH] (*) Add single-node barebones configuration This adds a single-node barebones configuration to the install script. It also moves the log4j configuration into system.properties, and sets assertions to disabled by default. --- run/env/service.env | 2 +- run/install.sh | 21 +- .../docker-compose-barebones-1.yml.template | 186 ++++++++++++++++++ ...> docker-compose-barebones-2.yml.template} | 0 run/template/conf/hosts | 0 .../conf/properties/system.properties | 2 + 6 files changed, 203 insertions(+), 8 deletions(-) create mode 100644 run/install/docker-compose-barebones-1.yml.template rename run/install/{docker-compose-barebones.yml.template => docker-compose-barebones-2.yml.template} (100%) delete mode 100644 run/template/conf/hosts diff --git a/run/env/service.env b/run/env/service.env index 6d63ba74..8a1e311f 100644 --- a/run/env/service.env +++ b/run/env/service.env @@ -1,5 +1,5 @@ WMSA_HOME=run/ -JAVA_OPTS="--enable-preview -ea -Dlog4j2.configurationFile=log4j2-test.xml -Dservice-host=0.0.0.0 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" +JAVA_OPTS="--enable-preview -da -Dservice-host=0.0.0.0 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" JAVA_TOOL_OPTIONS="--enable-preview -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5000" EXECUTOR_SERVICE_OPTS="-DdistPath=/dist" CONVERTER_PROCESS_OPTS="-Dservice-name=converter -Dservice-host=0.0.0.0" diff --git a/run/install.sh b/run/install.sh index 7452df6e..20550cd6 100755 --- a/run/install.sh +++ b/run/install.sh @@ -38,14 +38,15 @@ INSTALL_DIR=$(realpath ${1}) echo "Would you like to set up a:" echo -echo "1) barebones instance" -echo "2) full Marginalia Search instance?" -read -p "Enter 1 or 2: " INSTANCE_TYPE +echo "1) barebones instance (1 node)" +echo "2) barebones instance (2 nodes)" +echo "3) full Marginalia Search instance?" +read -p "Enter 1, 2 or 2: " INSTANCE_TYPE ## Validate -if [ "${INSTANCE_TYPE}" != "1" ] && [ "${INSTANCE_TYPE}" != "2" ]; then +if [ "${INSTANCE_TYPE}" != "1" ] && [ "${INSTANCE_TYPE}" != "2" ] && [ "${INSTANCE_TYPE}" != "3" ]; then echo - echo "ERROR: Invalid instance type, choose 1 or 2" + echo "ERROR: Invalid instance type, choose 1, 2 or 3" exit 1 fi @@ -91,6 +92,8 @@ done # for barebones, tell the control service to hide the marginalia app specific stuff if [ "${INSTANCE_TYPE}" == "1" ]; then echo "control.hideMarginaliaApp=true" > ${INSTALL_DIR}/conf/properties/control-service.properties +elif [ "${INSTANCE_TYPE}" == "2" ]; then + echo "control.hideMarginaliaApp=true" > ${INSTALL_DIR}/conf/properties/control-service.properties fi echo "** Copying settings files" @@ -100,7 +103,9 @@ echo "** Creating directories" mkdir -p ${INSTALL_DIR}/logs mkdir -p ${INSTALL_DIR}/db mkdir -p ${INSTALL_DIR}/index-1/{work,index,backup,storage,uploads} -mkdir -p ${INSTALL_DIR}/index-2/{work,index,backup,storage,uploads} +if [ "${INSTANCE_TYPE}" == "2" ] || [ "${INSTANCE_TYPE}" == "3" ]; then + mkdir -p ${INSTALL_DIR}/index-2/{work,index,backup,storage,uploads} +fi echo "** Updating settings files" @@ -116,7 +121,9 @@ export pval="\$\$MARIADB_PASSWORD" export INSTALL_DIR if [ "${INSTANCE_TYPE}" == "1" ]; then - envsubst < install/docker-compose-barebones.yml.template >${INSTALL_DIR}/docker-compose.yml + envsubst < install/docker-compose-barebones-1.yml.template >${INSTALL_DIR}/docker-compose.yml +elif [ "${INSTANCE_TYPE}" == "2" ]; then + envsubst < install/docker-compose-barebones-2.yml.template >${INSTALL_DIR}/docker-compose.yml else envsubst < install/docker-compose-marginalia.yml.template >${INSTALL_DIR}/docker-compose.yml fi diff --git a/run/install/docker-compose-barebones-1.yml.template b/run/install/docker-compose-barebones-1.yml.template new file mode 100644 index 00000000..1a08cc31 --- /dev/null +++ b/run/install/docker-compose-barebones-1.yml.template @@ -0,0 +1,186 @@ +x-svc: &service + env_file: + - "${INSTALL_DIR}/env/service.env" + volumes: + - conf:/wmsa/conf:ro + - model:/wmsa/model + - data:/wmsa/data + - logs:/var/log/wmsa + networks: + - wmsa + healthcheck: + test: curl -f http://localhost:80/internal/ping || exit 1 + start_period: 1s + interval: 5s + timeout: 5s + retries: 60 +x-p1: &partition-1 + env_file: + - "${INSTALL_DIR}/env/service.env" + healthcheck: + test: curl -f http://localhost:80/internal/ping || exit 1 + start_period: 1s + interval: 5s + timeout: 5s + retries: 60 + volumes: + - conf:/wmsa/conf:ro + - model:/wmsa/model + - data:/wmsa/data + - logs:/var/log/wmsa + - index-1:/idx + - work-1:/work + - backup-1:/backup + - storage-1:/storage + - uploads-1:/uploads + networks: + - wmsa + environment: + - "WMSA_SERVICE_NODE=1" +services: + index-service-1: + <<: *partition-1 + image: "marginalia/index-service" + container_name: "index-service-1" + depends_on: + control-service: + condition: service_healthy + executor-service-1: + <<: *partition-1 + image: "marginalia/executor-service" + container_name: "executor-service-1" + depends_on: + control-service: + condition: service_healthy + query-service: + <<: *service + image: "marginalia/query-service" + container_name: "query-service" + depends_on: + control-service: + condition: service_healthy + expose: + - 80 + labels: + - "traefik.enable=true" + - "traefik.http.routers.search-service.rule=PathPrefix(`/`)" + - "traefik.http.routers.search-service.entrypoints=search" + - "traefik.http.routers.search-service.middlewares=add-xpublic" + - "traefik.http.routers.search-service.middlewares=add-public" + - "traefik.http.middlewares.add-xpublic.headers.customrequestheaders.X-Public=1" + - "traefik.http.middlewares.add-public.addprefix.prefix=/public" + control-service: + <<: *service + image: "marginalia/control-service" + container_name: "control-service" + depends_on: + mariadb: + condition: service_healthy + expose: + - 80 + labels: + - "traefik.enable=true" + - "traefik.http.routers.control-service.rule=PathPrefix(`/`)" + - "traefik.http.routers.control-service.entrypoints=control" + - "traefik.http.routers.control-service.middlewares=add-xpublic" + - "traefik.http.routers.control-service.middlewares=add-public" + - "traefik.http.middlewares.add-xpublic.headers.customrequestheaders.X-Public=1" + - "traefik.http.middlewares.add-public.addprefix.prefix=/public" + mariadb: + image: "mariadb:lts" + container_name: "mariadb" + env_file: "${INSTALL_DIR}/env/mariadb.env" + command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci'] + ports: + - "127.0.0.1:3306:3306/tcp" + healthcheck: + test: mysqladmin ping -h 127.0.0.1 -u ${uval} --password=${pval} + start_period: 5s + interval: 5s + timeout: 5s + retries: 60 + volumes: + - db:/var/lib/mysql + networks: + - wmsa + traefik: + image: "traefik:v2.10" + container_name: "traefik" + command: + #- "--log.level=DEBUG" + - "--api.insecure=true" + - "--providers.docker=true" + - "--providers.docker.exposedbydefault=false" + - "--entrypoints.search.address=:80" + - "--entrypoints.control.address=:81" + ports: + - "127.0.0.1:8080:80" + - "127.0.0.1:8081:81" + - "127.0.0.1:8090:8080" + volumes: + - "/var/run/docker.sock:/var/run/docker.sock:ro" + networks: + - wmsa +networks: + wmsa: +volumes: + db: + driver: local + driver_opts: + type: none + o: bind + device: ${INSTALL_DIR}/db + logs: + driver: local + driver_opts: + type: none + o: bind + device: ${INSTALL_DIR}/logs + model: + driver: local + driver_opts: + type: none + o: bind + device: ${INSTALL_DIR}/model + conf: + driver: local + driver_opts: + type: none + o: bind + device: ${INSTALL_DIR}/conf + data: + driver: local + driver_opts: + type: none + o: bind + device: ${INSTALL_DIR}/data + storage-1: + driver: local + driver_opts: + type: none + o: bind + device: ${INSTALL_DIR}/index-1/storage + uploads-1: + driver: local + driver_opts: + type: none + o: bind + device: ${INSTALL_DIR}/index-1/uploads + index-1: + driver: local + driver_opts: + type: none + o: bind + device: ${INSTALL_DIR}/index-1/index + work-1: + driver: local + driver_opts: + type: none + o: bind + device: ${INSTALL_DIR}/index-1/work + backup-1: + driver: local + driver_opts: + type: none + o: bind + device: ${INSTALL_DIR}/index-1/backup \ No newline at end of file diff --git a/run/install/docker-compose-barebones.yml.template b/run/install/docker-compose-barebones-2.yml.template similarity index 100% rename from run/install/docker-compose-barebones.yml.template rename to run/install/docker-compose-barebones-2.yml.template diff --git a/run/template/conf/hosts b/run/template/conf/hosts deleted file mode 100644 index e69de29b..00000000 diff --git a/run/template/conf/properties/system.properties b/run/template/conf/properties/system.properties index aa5b7ffa..b09772ca 100644 --- a/run/template/conf/properties/system.properties +++ b/run/template/conf/properties/system.properties @@ -2,6 +2,8 @@ crawler.userAgentString = Mozilla/5.0 (compatible) crawler.userAgentIdentifier = GoogleBot crawler.poolSize = 256 +log4j2.configurationFile=log4j2-test.xml + search.websiteUrl = http://localhost:8080/ executor.uploadDir = /uploads