From 5692d094556228da89d9d41886c2e1ef87082f6a Mon Sep 17 00:00:00 2001 From: skywalker Date: Fri, 15 Nov 2024 11:12:57 +0800 Subject: [PATCH] fix start notification-server --- .../docker/notification-server/standalone/env | 19 ++++++ .../standalone/notification-server.yml | 34 +++++++++++ manual/extension/notification-server.md | 58 +++++++++++++++---- 3 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 manual/docker/notification-server/standalone/env create mode 100644 manual/docker/notification-server/standalone/notification-server.yml diff --git a/manual/docker/notification-server/standalone/env b/manual/docker/notification-server/standalone/env new file mode 100644 index 000000000..18a086500 --- /dev/null +++ b/manual/docker/notification-server/standalone/env @@ -0,0 +1,19 @@ +COMPOSE_FILE='notification-server.yml' +COMPOSE_PATH_SEPARATOR=',' + + +NOTIFICATION_SERVER_IMAGE=seafileltd/notification-server:12.0-latest + +NOTIFICATION_SERVER_VOLUME=/opt/notification-data + +SEAFILE_MYSQL_DB_HOST=192.168.0.2 +SEAFILE_MYSQL_DB_USER=seafile +SEAFILE_MYSQL_DB_PASSWORD=PASSWORD + +TIME_ZONE=Etc/UTC + +JWT_PRIVATE_KEY= + +SEAFILE_SERVER_HOSTNAME=example.seafile.com +SEAFILE_SERVER_PROTOCOL=http + diff --git a/manual/docker/notification-server/standalone/notification-server.yml b/manual/docker/notification-server/standalone/notification-server.yml new file mode 100644 index 000000000..b55d11fb9 --- /dev/null +++ b/manual/docker/notification-server/standalone/notification-server.yml @@ -0,0 +1,34 @@ +services: + + notification-server: + image: ${NOTIFICATION_SERVER_IMAGE:-seafileltd/notification-server:12.0-latest} + container_name: notification-server + restart: always + volumes: + - ${NOTIFICATION_SERVER_VOLUME:-/opt/notification-data}:/shared + ports: + - "8083:8083" + environment: + - SEAFILE_MYSQL_DB_HOST=${SEAFILE_MYSQL_DB_HOST:-db} + - SEAFILE_MYSQL_DB_PORT=${SEAFILE_MYSQL_DB_PORT:-3306} + - SEAFILE_MYSQL_DB_USER=${SEAFILE_MYSQL_DB_USER:-seafile} + - SEAFILE_MYSQL_DB_PASSWORD=${SEAFILE_MYSQL_DB_PASSWORD:?Variable is not set or empty} + - SEAFILE_MYSQL_DB_CCNET_DB_NAME=${SEAFILE_MYSQL_DB_CCNET_DB_NAME:-ccnet_db} + - SEAFILE_MYSQL_DB_SEAFILE_DB_NAME=${SEAFILE_MYSQL_DB_SEAFILE_DB_NAME:-seafile_db} + - JWT_PRIVATE_KEY=${JWT_PRIVATE_KEY:?Variable is not set or empty} + - SEAFILE_LOG_TO_STDOUT=${SEAFILE_LOG_TO_STDOUT:-false} + - NOTIFICATION_SERVER_LOG_LEVEL=${NOTIFICATION_SERVER_LOG_LEVEL:-info} + labels: + caddy: ${SEAFILE_SERVER_PROTOCOL:-http}://${SEAFILE_SERVER_HOSTNAME:?Variable is not set or empty} + caddy.@ws.0_header: "Connection *Upgrade*" + caddy.@ws.1_header: "Upgrade websocket" + caddy.0_reverse_proxy: "@ws {{upstreams 8083}}" + caddy.1_handle_path: "/notification*" + caddy.1_handle_path.0_rewrite: "* {uri}" + caddy.1_handle_path.1_reverse_proxy: "{{upstreams 8083}}" + networks: + - seafile-net + +networks: + seafile-net: + name: seafile-net diff --git a/manual/extension/notification-server.md b/manual/extension/notification-server.md index 6f9c045ab..e13daddd5 100644 --- a/manual/extension/notification-server.md +++ b/manual/extension/notification-server.md @@ -15,21 +15,33 @@ The notification server uses websocket protocol and maintains a two-way communic ## How to configure and run -Since Seafile 12.0, we use docker to deploy the notification server. First deploy Seafile docker, then download `notification-server.yml` and modify the `.env` file: +Since Seafile 12.0, we use docker to deploy the notification server. First deploy Seafile docker, then download `notification-server.yml` to Seafile directory and modify the `.env` file: ```sh wget https://manual.seafile.com/12.0/docker/notification-server.yml ``` -Modify `.env`, and insert `notification-server.yml` into `COMPOSE_FILE` +Modify `.env`, and insert `notification-server.yml` into `COMPOSE_FILE`: ```env COMPOSE_FILE='seafile-server.yml,caddy.yml,notification-server.yml' ``` +And you need to add the following configurations under seafile.conf: + +```conf +[notification] +enabled = true +# the ip of notification server. (default is `notification-server` in Docker) +host = notification-server +# the port of notification server +port = 8083 +``` + You can run notification server with the following command: ```sh +docker compose down docker compose up -d ``` @@ -54,17 +66,41 @@ There is no additional features for notification server in the Pro Edition. It w If you enable [clustering](../setup_binary/deploy_in_a_cluster.md), You need to deploy notification server on one of the servers, or a separate server. The load balancer should forward websockets requests to this node. -Modify `notification-server.yml`, and open 8083 port +Download `.env` and `notification-server.yml` to Notification server directory: + +```sh +wget https://manual.seafile.com/12.0/docker/notification-server/standalone/notification-server.yml +wget -o .env https://manual.seafile.com/12.0/docker/notification-server/standalone/env +``` + +Then modify the `.env` file according to your environment. The following fields are needed to be modified: + +| variable | description | +|------------------------|---------------------------------------------------------------------------------------------------------------| +| `NOTIFICATION_SERVER_VOLUME` | The volume directory of Notification Server data | +| `SEAFILE_MYSQL_DB_HOST`| Seafile MySQL host | +| `SEAFILE_MYSQL_DB_USER`| Seafile MySQL user, default is `seafile` | +| `SEAFILE_MYSQL_DB_PASSWORD`| Seafile MySQL password | +| `TIME_ZONE` | Time zone | +| `JWT_PRIVATE_KEY` | JWT key, the same as the config in Seafile `.env` file | +| `SEAFILE_SERVER_HOSTNAME`| Seafile host name | +| `SEAFILE_SERVER_PROTOCOL`| http or https | + +You can run notification server with the following command: + +```sh +docker compose up -d +``` -```yml -services: +And you need to add the following configurations under `seafile.conf` and restart Seafile server: - notification-server: - image: ${NOTIFICATION_SERVER_IMAGE:-seafileltd/notification-server:12.0-latest} - ... - ports: - - "8083:8083" - ... +```conf +[notification] +enabled = true +# the ip of notification server. +host = 192.168.0.83 +# the port of notification server +port = 8083 ``` You need to configure load balancer according to the following forwarding rules: