当前位置:   article > 正文

Docker无法部署Onlyoffice问题记录_docker onlyoffice 无法访问

docker onlyoffice 无法访问

Docker无法部署Onlyoffice问题记录

1、问题描述

国产操作系统(麒麟v10-x86-64bit,openEuler20.03 64bit x86),安装docker之后,通过docker run之后Onlyoffice无法成功跑起来,且会消耗大量cpu资源,甚至导致系统卡死

1630589238649

2、原因分析

镜像的entrypoint中指向运行一个sh脚本,脚本中通过service命令启动rabbitmq,但是一直无法成功启动,且一直处于循环尝试导致cpu占用上升

3、解决方案

经测试,进入onlyoffice容器后可以通过内置的rabbitmq的脚本启动rabbitmq

找到其它解决方案,修改onlyoffice entrypoint脚本,使用默认rabbitmq脚本启动rabbitmq

解决方式如下

  1. 在onlyoffice对应宿主机上编写一个脚本,内容如下

    #!/bin/bash
    
    # Define '**' behavior explicitly
    shopt -s globstar
    
    APP_DIR="/var/www/${COMPANY_NAME}/documentserver"
    DATA_DIR="/var/www/${COMPANY_NAME}/Data"
    LOG_DIR="/var/log/${COMPANY_NAME}"
    DS_LOG_DIR="${LOG_DIR}/documentserver"
    LIB_DIR="/var/lib/${COMPANY_NAME}"
    DS_LIB_DIR="${LIB_DIR}/documentserver"
    CONF_DIR="/etc/${COMPANY_NAME}/documentserver"
    
    ONLYOFFICE_DATA_CONTAINER=${ONLYOFFICE_DATA_CONTAINER:-false}
    ONLYOFFICE_DATA_CONTAINER_HOST=${ONLYOFFICE_DATA_CONTAINER_HOST:-localhost}
    ONLYOFFICE_DATA_CONTAINER_PORT=80
    
    SSL_CERTIFICATES_DIR="${DATA_DIR}/certs"
    if [[ -z $SSL_CERTIFICATE_PATH ]] && [[ -f ${SSL_CERTIFICATES_DIR}/onlyoffice.crt ]]; then
      SSL_CERTIFICATE_PATH=${SSL_CERTIFICATES_DIR}/onlyoffice.crt
    else
      SSL_CERTIFICATE_PATH=${SSL_CERTIFICATE_PATH:-${SSL_CERTIFICATES_DIR}/tls.crt}
    fi
    if [[ -z $SSL_KEY_PATH ]] && [[ -f ${SSL_CERTIFICATES_DIR}/onlyoffice.key ]]; then
      SSL_KEY_PATH=${SSL_CERTIFICATES_DIR}/onlyoffice.key
    else
      SSL_KEY_PATH=${SSL_KEY_PATH:-${SSL_CERTIFICATES_DIR}/tls.key}
    fi
    CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-${SSL_CERTIFICATES_DIR}/ca-certificates.pem}
    SSL_DHPARAM_PATH=${SSL_DHPARAM_PATH:-${SSL_CERTIFICATES_DIR}/dhparam.pem}
    SSL_VERIFY_CLIENT=${SSL_VERIFY_CLIENT:-off}
    USE_UNAUTHORIZED_STORAGE=${USE_UNAUTHORIZED_STORAGE:-false}
    ONLYOFFICE_HTTPS_HSTS_ENABLED=${ONLYOFFICE_HTTPS_HSTS_ENABLED:-true}
    ONLYOFFICE_HTTPS_HSTS_MAXAGE=${ONLYOFFICE_HTTPS_HSTS_MAXAGE:-31536000}
    SYSCONF_TEMPLATES_DIR="/app/ds/setup/config"
    
    NGINX_CONFD_PATH="/etc/nginx/conf.d";
    NGINX_ONLYOFFICE_PATH="${CONF_DIR}/nginx"
    NGINX_ONLYOFFICE_CONF="${NGINX_ONLYOFFICE_PATH}/ds.conf"
    NGINX_ONLYOFFICE_EXAMPLE_PATH="${CONF_DIR}-example/nginx"
    NGINX_ONLYOFFICE_EXAMPLE_CONF="${NGINX_ONLYOFFICE_EXAMPLE_PATH}/includes/ds-example.conf"
    
    NGINX_CONFIG_PATH="/etc/nginx/nginx.conf"
    NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1}
    NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-$(ulimit -n)}
    
    JWT_ENABLED=${JWT_ENABLED:-false}
    JWT_SECRET=${JWT_SECRET:-secret}
    JWT_HEADER=${JWT_HEADER:-Authorization}
    JWT_IN_BODY=${JWT_IN_BODY:-false}
    
    if [[ ${PRODUCT_NAME} == "documentserver" ]]; then
      REDIS_ENABLED=false
    else
      REDIS_ENABLED=true
    fi
    
    ONLYOFFICE_DEFAULT_CONFIG=${CONF_DIR}/local.json
    ONLYOFFICE_LOG4JS_CONFIG=${CONF_DIR}/log4js/production.json
    ONLYOFFICE_EXAMPLE_CONFIG=${CONF_DIR}-example/local.json
    
    JSON_BIN=${APP_DIR}/npm/json
    JSON="${JSON_BIN} -q -f ${ONLYOFFICE_DEFAULT_CONFIG}"
    JSON_LOG="${JSON_BIN} -q -f ${ONLYOFFICE_LOG4JS_CONFIG}"
    JSON_EXAMPLE="${JSON_BIN} -q -f ${ONLYOFFICE_EXAMPLE_CONFIG}"
    
    LOCAL_SERVICES=()
    
    PG_ROOT=/var/lib/postgresql
    PG_VERSION=10
    PG_NAME=main
    PGDATA=${PG_ROOT}/${PG_VERSION}/${PG_NAME}
    PG_NEW_CLUSTER=false
    RABBITMQ_DATA=/var/lib/rabbitmq
    REDIS_DATA=/var/lib/redis
    
    read_setting(){
      deprecated_var POSTGRESQL_SERVER_HOST DB_HOST
      deprecated_var POSTGRESQL_SERVER_PORT DB_PORT
      deprecated_var POSTGRESQL_SERVER_DB_NAME DB_NAME
      deprecated_var POSTGRESQL_SERVER_USER DB_USER
      deprecated_var POSTGRESQL_SERVER_PASS DB_PWD
      deprecated_var RABBITMQ_SERVER_URL AMQP_URI
      deprecated_var AMQP_SERVER_URL AMQP_URI
      deprecated_var AMQP_SERVER_TYPE AMQP_TYPE
    
      METRICS_ENABLED="${METRICS_ENABLED:-false}"
      METRICS_HOST="${METRICS_HOST:-localhost}"
      METRICS_PORT="${METRICS_PORT:-8125}"
      METRICS_PREFIX="${METRICS_PREFIX:-.ds}"
    
      DB_HOST=${DB_HOST:-${POSTGRESQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}}
      case $DB_TYPE in
        "postgres")
          DB_PORT=${DB_PORT:-"5432"}
          ;;
        "mariadb"|"mysql")
          DB_PORT=${DB_PORT:-"3306"}
          ;;
        "")
          DB_PORT=${DB_PORT:-${POSTGRESQL_SERVER_PORT:-$(${JSON} services.CoAuthoring.sql.dbPort)}}
          ;;
        *)
          echo "ERROR: unknown database type"
          exit 1
          ;;
      esac
      DB_NAME=${DB_NAME:-${POSTGRESQL_SERVER_DB_NAME:-$(${JSON} services.CoAuthoring.sql.dbName)}}
      DB_USER=${DB_USER:-${POSTGRESQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)}}
      DB_PWD=${DB_PWD:-${POSTGRESQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)}}
      DB_TYPE=${DB_TYPE:-$(${JSON} services.CoAuthoring.sql.type)}
    
      RABBITMQ_SERVER_URL=${RABBITMQ_SERVER_URL:-$(${JSON} rabbitmq.url)}
      AMQP_URI=${AMQP_URI:-${AMQP_SERVER_URL:-${RABBITMQ_SERVER_URL}}}
      AMQP_TYPE=${AMQP_TYPE:-${AMQP_SERVER_TYPE:-rabbitmq}}
      parse_rabbitmq_url ${AMQP_URI}
    
      REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-$(${JSON} services.CoAuthoring.redis.host)}
      REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-6379}
    
      DS_LOG_LEVEL=${DS_LOG_LEVEL:-$(${JSON_LOG} categories.default.level)}
    }
    
    deprecated_var() {
      if [[ -n ${!1} ]]; then
        echo "Variable $1 is deprecated. Use $2 instead."
      fi
    }
    
    parse_rabbitmq_url(){
      local amqp=$1
    
      # extract the protocol
      local proto="$(echo $amqp | grep :// | sed -e's,^\(.*://\).*,\1,g')"
      # remove the protocol
      local url="$(echo ${amqp/$proto/})"
    
      # extract the user and password (if any)
      local userpass="`echo $url | grep @ | cut -d@ -f1`"
      local pass=`echo $userpass | grep : | cut -d: -f2`
    
      local user
      if [ -n "$pass" ]; then
        user=`echo $userpass | grep : | cut -d: -f1`
      else
        user=$userpass
      fi
    
      # extract the host
      local hostport="$(echo ${url/$userpass@/} | cut -d/ -f1)"
      # by request - try to extract the port
      local port="$(echo $hostport | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
    
      local host
      if [ -n "$port" ]; then
        host=`echo $hostport | grep : | cut -d: -f1`
      else
        host=$hostport
        port="5672"
      fi
    
      # extract the path (if any)
      local path="$(echo $url | grep / | cut -d/ -f2-)"
    
      AMQP_SERVER_PROTO=${proto:0:-3}
      AMQP_SERVER_HOST=$host
      AMQP_SERVER_USER=$user
      AMQP_SERVER_PASS=$pass
      AMQP_SERVER_PORT=$port
    }
    
    waiting_for_connection(){
      until nc -z -w 3 "$1" "$2"; do
        >&2 echo "Waiting for connection to the $1 host on port $2"
        sleep 1
      done
    }
    
    waiting_for_db(){
      waiting_for_connection $DB_HOST $DB_PORT
    }
    
    waiting_for_amqp(){
      waiting_for_connection ${AMQP_SERVER_HOST} ${AMQP_SERVER_PORT}
    }
    
    waiting_for_redis(){
      waiting_for_connection ${REDIS_SERVER_HOST} ${REDIS_SERVER_PORT}
    }
    waiting_for_datacontainer(){
      waiting_for_connection ${ONLYOFFICE_DATA_CONTAINER_HOST} ${ONLYOFFICE_DATA_CONTAINER_PORT}
    }
    
    update_statsd_settings(){
      ${JSON} -I -e "if(this.statsd===undefined)this.statsd={};"
      ${JSON} -I -e "this.statsd.useMetrics = '${METRICS_ENABLED}'"
      ${JSON} -I -e "this.statsd.host = '${METRICS_HOST}'"
      ${JSON} -I -e "this.statsd.port = '${METRICS_PORT}'"
      ${JSON} -I -e "this.statsd.prefix = '${METRICS_PREFIX}'"
    }
    
    update_db_settings(){
      ${JSON} -I -e "this.services.CoAuthoring.sql.type = '${DB_TYPE}'"
      ${JSON} -I -e "this.services.CoAuthoring.sql.dbHost = '${DB_HOST}'"
      ${JSON} -I -e "this.services.CoAuthoring.sql.dbPort = '${DB_PORT}'"
      ${JSON} -I -e "this.services.CoAuthoring.sql.dbName = '${DB_NAME}'"
      ${JSON} -I -e "this.services.CoAuthoring.sql.dbUser = '${DB_USER}'"
      ${JSON} -I -e "this.services.CoAuthoring.sql.dbPass = '${DB_PWD}'"
    }
    
    update_rabbitmq_setting(){
      if [ "${AMQP_TYPE}" == "rabbitmq" ]; then
        ${JSON} -I -e "if(this.queue===undefined)this.queue={};"
        ${JSON} -I -e "this.queue.type = 'rabbitmq'"
        ${JSON} -I -e "this.rabbitmq.url = '${AMQP_URI}'"
      fi
      
      if [ "${AMQP_TYPE}" == "activemq" ]; then
        ${JSON} -I -e "if(this.queue===undefined)this.queue={};"
        ${JSON} -I -e "this.queue.type = 'activemq'"
        ${JSON} -I -e "if(this.activemq===undefined)this.activemq={};"
        ${JSON} -I -e "if(this.activemq.connectOptions===undefined)this.activemq.connectOptions={};"
    
        ${JSON} -I -e "this.activemq.connectOptions.host = '${AMQP_SERVER_HOST}'"
    
        if [ ! "${AMQP_SERVER_PORT}" == "" ]; then
          ${JSON} -I -e "this.activemq.connectOptions.port = '${AMQP_SERVER_PORT}'"
        else
          ${JSON} -I -e "delete this.activemq.connectOptions.port"
        fi
    
        if [ ! "${AMQP_SERVER_USER}" == "" ]; then
          ${JSON} -I -e "this.activemq.connectOptions.username = '${AMQP_SERVER_USER}'"
        else
          ${JSON} -I -e "delete this.activemq.connectOptions.username"
        fi
    
        if [ ! "${AMQP_SERVER_PASS}" == "" ]; then
          ${JSON} -I -e "this.activemq.connectOptions.password = '${AMQP_SERVER_PASS}'"
        else
          ${JSON} -I -e "delete this.activemq.connectOptions.password"
        fi
    
        case "${AMQP_SERVER_PROTO}" in
          amqp+ssl|amqps)
            ${JSON} -I -e "this.activemq.connectOptions.transport = 'tls'"
            ;;
          *)
            ${JSON} -I -e "delete this.activemq.connectOptions.transport"
            ;;
        esac 
      fi
    }
    
    update_redis_settings(){
      ${JSON} -I -e "this.services.CoAuthoring.redis.host = '${REDIS_SERVER_HOST}'"
      ${JSON} -I -e "this.services.CoAuthoring.redis.port = '${REDIS_SERVER_PORT}'"
    }
    
    update_ds_settings(){
      if [ "${JWT_ENABLED}" == "true" ]; then
        ${JSON} -I -e "this.services.CoAuthoring.token.enable.browser = ${JWT_ENABLED}"
        ${JSON} -I -e "this.services.CoAuthoring.token.enable.request.inbox = ${JWT_ENABLED}"
        ${JSON} -I -e "this.services.CoAuthoring.token.enable.request.outbox = ${JWT_ENABLED}"
    
        ${JSON} -I -e "this.services.CoAuthoring.secret.inbox.string = '${JWT_SECRET}'"
        ${JSON} -I -e "this.services.CoAuthoring.secret.outbox.string = '${JWT_SECRET}'"
        ${JSON} -I -e "this.services.CoAuthoring.secret.session.string = '${JWT_SECRET}'"
    
        ${JSON} -I -e "this.services.CoAuthoring.token.inbox.header = '${JWT_HEADER}'"
        ${JSON} -I -e "this.services.CoAuthoring.token.outbox.header = '${JWT_HEADER}'"
    
        ${JSON} -I -e "this.services.CoAuthoring.token.inbox.inBody = ${JWT_IN_BODY}"
        ${JSON} -I -e "this.services.CoAuthoring.token.outbox.inBody = ${JWT_IN_BODY}"
    
        if [ -f "${ONLYOFFICE_EXAMPLE_CONFIG}" ] && [ "${JWT_ENABLED}" == "true" ]; then
          ${JSON_EXAMPLE} -I -e "this.server.token.enable = ${JWT_ENABLED}"
          ${JSON_EXAMPLE} -I -e "this.server.token.secret = '${JWT_SECRET}'"
          ${JSON_EXAMPLE} -I -e "this.server.token.authorizationHeader = '${JWT_HEADER}'"
        fi
      fi
    
      if [ "${USE_UNAUTHORIZED_STORAGE}" == "true" ]; then
        ${JSON} -I -e "if(this.services.CoAuthoring.requestDefaults===undefined)this.services.CoAuthoring.requestDefaults={}"
        ${JSON} -I -e "if(this.services.CoAuthoring.requestDefaults.rejectUnauthorized===undefined)this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false"
      fi
    }
    
    create_postgresql_cluster(){
      local pg_conf_dir=/etc/postgresql/${PG_VERSION}/${PG_NAME}
      local postgresql_conf=$pg_conf_dir/postgresql.conf
      local hba_conf=$pg_conf_dir/pg_hba.conf
    
      mv $postgresql_conf $postgresql_conf.backup
      mv $hba_conf $hba_conf.backup
    
      pg_createcluster ${PG_VERSION} ${PG_NAME}
    }
    
    create_postgresql_db(){
      sudo -u postgres psql -c "CREATE DATABASE $DB_NAME;"
      sudo -u postgres psql -c "CREATE USER $DB_USER WITH password '"$DB_PWD"';"
      sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE $DB_NAME TO $DB_USER;"
    }
    
    create_db_tbl() {
      case $DB_TYPE in
        "postgres")
          create_postgresql_tbl
        ;;
        "mariadb"|"mysql")
          create_mysql_tbl
        ;;
      esac
    }
    
    create_postgresql_tbl() {
      CONNECTION_PARAMS="-h$DB_HOST -p$DB_PORT -U$DB_USER -w"
      if [ -n "$DB_PWD" ]; then
        export PGPASSWORD=$DB_PWD
      fi
    
      PSQL="psql -q $CONNECTION_PARAMS"
      CREATEDB="createdb $CONNECTION_PARAMS"
    
      # Create db on remote server
      if $PSQL -lt | cut -d\| -f 1 | grep -qw $DB_NAME | grep 0; then
        $CREATEDB $DB_NAME
      fi
    
      $PSQL -d "$DB_NAME" -f "$APP_DIR/server/schema/postgresql/createdb.sql"
    }
    
    create_mysql_tbl() {
      CONNECTION_PARAMS="-h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PWD -w"
      MYSQL="mysql -q $CONNECTION_PARAMS"
    
      # Create db on remote server
      $MYSQL -e "CREATE DATABASE IF NOT EXISTS $DB_NAME DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" >/dev/null 2>&1
    
      $MYSQL $DB_NAME < "$APP_DIR/server/schema/mysql/createdb.sql" >/dev/null 2>&1
    }
    
    update_welcome_page() {
      WELCOME_PAGE="${APP_DIR}-example/welcome/docker.html"
      if [[ -e $WELCOME_PAGE ]]; then
        DOCKER_CONTAINER_ID=$(basename $(cat /proc/1/cpuset))
        if [[ -x $(command -v docker) ]]; then
          DOCKER_CONTAINER_NAME=$(docker inspect --format="{{.Name}}" $DOCKER_CONTAINER_ID)
          sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_NAME#/}"'/' -i $WELCOME_PAGE
        else
          sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_ID::12}"'/' -i $WELCOME_PAGE
        fi
      fi
    }
    
    update_nginx_settings(){
      # Set up nginx
      sed 's/^worker_processes.*/'"worker_processes ${NGINX_WORKER_PROCESSES};"'/' -i ${NGINX_CONFIG_PATH}
      sed 's/worker_connections.*/'"worker_connections ${NGINX_WORKER_CONNECTIONS};"'/' -i ${NGINX_CONFIG_PATH}
      sed 's/access_log.*/'"access_log off;"'/' -i ${NGINX_CONFIG_PATH}
    
      # setup HTTPS
      if [ -f "${SSL_CERTIFICATE_PATH}" -a -f "${SSL_KEY_PATH}" ]; then
        cp -f ${NGINX_ONLYOFFICE_PATH}/ds-ssl.conf.tmpl ${NGINX_ONLYOFFICE_CONF}
    
        # configure nginx
        sed 's,{{SSL_CERTIFICATE_PATH}},'"${SSL_CERTIFICATE_PATH}"',' -i ${NGINX_ONLYOFFICE_CONF}
        sed 's,{{SSL_KEY_PATH}},'"${SSL_KEY_PATH}"',' -i ${NGINX_ONLYOFFICE_CONF}
    
        # turn on http2
        sed 's,\(443 ssl\),\1 http2,' -i ${NGINX_ONLYOFFICE_CONF}
    
        # if dhparam path is valid, add to the config, otherwise remove the option
        if [ -r "${SSL_DHPARAM_PATH}" ]; then
          sed 's,\(\#* *\)\?\(ssl_dhparam \).*\(;\)$,'"\2${SSL_DHPARAM_PATH}\3"',' -i ${NGINX_ONLYOFFICE_CONF}
        else
          sed '/ssl_dhparam/d' -i ${NGINX_ONLYOFFICE_CONF}
        fi
    
        sed 's,\(ssl_verify_client \).*\(;\)$,'"\1${SSL_VERIFY_CLIENT}\2"',' -i ${NGINX_ONLYOFFICE_CONF}
    
        if [ -f "${CA_CERTIFICATES_PATH}" ]; then
          sed '/ssl_verify_client/a '"ssl_client_certificate ${CA_CERTIFICATES_PATH}"';' -i ${NGINX_ONLYOFFICE_CONF}
        fi
    
        if [ "${ONLYOFFICE_HTTPS_HSTS_ENABLED}" == "true" ]; then
          sed 's,\(max-age=\).*\(;\)$,'"\1${ONLYOFFICE_HTTPS_HSTS_MAXAGE}\2"',' -i ${NGINX_ONLYOFFICE_CONF}
        else
          sed '/max-age=/d' -i ${NGINX_ONLYOFFICE_CONF}
        fi
      else
        ln -sf ${NGINX_ONLYOFFICE_PATH}/ds.conf.tmpl ${NGINX_ONLYOFFICE_CONF}
      fi
    
      # check if ipv6 supported otherwise remove it from nginx config
      if [ ! -f /proc/net/if_inet6 ]; then
        sed '/listen\s\+\[::[0-9]*\].\+/d' -i $NGINX_ONLYOFFICE_CONF
      fi
    
      if [ -f "${NGINX_ONLYOFFICE_EXAMPLE_CONF}" ]; then
        sed 's/linux/docker/' -i ${NGINX_ONLYOFFICE_EXAMPLE_CONF}
      fi
    }
    
    update_supervisor_settings(){
      # Copy modified supervisor start script
      cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisor /etc/init.d/
      # Copy modified supervisor config
      cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
    }
    
    update_log_settings(){
       ${JSON_LOG} -I -e "this.categories.default.level = '${DS_LOG_LEVEL}'"
    }
    
    update_logrotate_settings(){
      sed 's|\(^su\b\).*|\1 root root|' -i /etc/logrotate.conf
    }
    
    # create base folders
    for i in converter docservice spellchecker metrics; do
      mkdir -p "${DS_LOG_DIR}/$i"
    done
    
    mkdir -p ${DS_LOG_DIR}-example
    
    # create app folders
    for i in ${DS_LIB_DIR}/App_Data/cache/files ${DS_LIB_DIR}/App_Data/docbuilder ${DS_LIB_DIR}-example/files; do
      mkdir -p "$i"
    done
    
    # change folder rights
    for i in ${LOG_DIR} ${LIB_DIR} ${DATA_DIR}; do
      chown -R ds:ds "$i"
      chmod -R 755 "$i"
    done
    
    if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then
    
      read_setting
    
      if [ $METRICS_ENABLED = "true" ]; then
        update_statsd_settings
      fi
    
      update_welcome_page
    
      update_log_settings
    
      update_ds_settings
    
      # update settings by env variables
      if [ $DB_HOST != "localhost" ]; then
        update_db_settings
        waiting_for_db
        create_db_tbl
      else
        # change rights for postgres directory
        chown -R postgres:postgres ${PG_ROOT}
        chmod -R 700 ${PG_ROOT}
    
        # create new db if it isn't exist
        if [ ! -d ${PGDATA} ]; then
          create_postgresql_cluster
          PG_NEW_CLUSTER=true
        fi
        LOCAL_SERVICES+=("postgresql")
      fi
    
      if [ ${AMQP_SERVER_HOST} != "localhost" ]; then
        update_rabbitmq_setting
      else
        # change rights for rabbitmq directory
        chown -R rabbitmq:rabbitmq ${RABBITMQ_DATA}
        chmod -R go=rX,u=rwX ${RABBITMQ_DATA}
        if [ -f ${RABBITMQ_DATA}/.erlang.cookie ]; then
            chmod 400 ${RABBITMQ_DATA}/.erlang.cookie
        fi
    
        LOCAL_SERVICES+=("rabbitmq-server")
        # allow Rabbitmq startup after container kill
        rm -rf /var/run/rabbitmq
      fi
    
      if [ ${REDIS_ENABLED} = "true" ]; then
        if [ ${REDIS_SERVER_HOST} != "localhost" ]; then
          update_redis_settings
        else
          # change rights for redis directory
          chown -R redis:redis ${REDIS_DATA}
          chmod -R 750 ${REDIS_DATA}
    
          LOCAL_SERVICES+=("redis-server")
        fi
      fi
    else
      # no need to update settings just wait for remote data
      waiting_for_datacontainer
    
      # read settings after the data container in ready state
      # to prevent get unconfigureted data
      read_setting
      
      update_welcome_page
    fi
    
    #start needed local services
    /usr/sbin/rabbitmq-server &
    service supervisor start
    service cron start
    service nginx start
    ./usr/bin/documentserver-generate-allfonts.sh
    ./usr/bin/documentserver-static-gzip.sh
    for i in ${LOCAL_SERVICES[@]}; do
      service $i start
    done
    
    if [ ${PG_NEW_CLUSTER} = "true" ]; then
      create_postgresql_db
      create_postgresql_tbl
    fi
    
    if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
      waiting_for_db
      waiting_for_amqp
      if [ ${REDIS_ENABLED} = "true" ]; then
        waiting_for_redis
      fi
    
      update_nginx_settings
    
      update_supervisor_settings
      service supervisor start
      
      # start cron to enable log rotating
      update_logrotate_settings
      service cron start
    fi
    
    # nginx used as a proxy, and as data container status service.
    # it run in all cases.
    service nginx start
    wait
    wait
    # Regenerate the fonts list and the fonts thumbnails
    documentserver-generate-allfonts.sh ${ONLYOFFICE_DATA_CONTAINER}
    documentserver-static-gzip.sh ${ONLYOFFICE_DATA_CONTAINER}
    
    tail -f /var/log/${COMPANY_NAME}/**/*.log
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
    • 303
    • 304
    • 305
    • 306
    • 307
    • 308
    • 309
    • 310
    • 311
    • 312
    • 313
    • 314
    • 315
    • 316
    • 317
    • 318
    • 319
    • 320
    • 321
    • 322
    • 323
    • 324
    • 325
    • 326
    • 327
    • 328
    • 329
    • 330
    • 331
    • 332
    • 333
    • 334
    • 335
    • 336
    • 337
    • 338
    • 339
    • 340
    • 341
    • 342
    • 343
    • 344
    • 345
    • 346
    • 347
    • 348
    • 349
    • 350
    • 351
    • 352
    • 353
    • 354
    • 355
    • 356
    • 357
    • 358
    • 359
    • 360
    • 361
    • 362
    • 363
    • 364
    • 365
    • 366
    • 367
    • 368
    • 369
    • 370
    • 371
    • 372
    • 373
    • 374
    • 375
    • 376
    • 377
    • 378
    • 379
    • 380
    • 381
    • 382
    • 383
    • 384
    • 385
    • 386
    • 387
    • 388
    • 389
    • 390
    • 391
    • 392
    • 393
    • 394
    • 395
    • 396
    • 397
    • 398
    • 399
    • 400
    • 401
    • 402
    • 403
    • 404
    • 405
    • 406
    • 407
    • 408
    • 409
    • 410
    • 411
    • 412
    • 413
    • 414
    • 415
    • 416
    • 417
    • 418
    • 419
    • 420
    • 421
    • 422
    • 423
    • 424
    • 425
    • 426
    • 427
    • 428
    • 429
    • 430
    • 431
    • 432
    • 433
    • 434
    • 435
    • 436
    • 437
    • 438
    • 439
    • 440
    • 441
    • 442
    • 443
    • 444
    • 445
    • 446
    • 447
    • 448
    • 449
    • 450
    • 451
    • 452
    • 453
    • 454
    • 455
    • 456
    • 457
    • 458
    • 459
    • 460
    • 461
    • 462
    • 463
    • 464
    • 465
    • 466
    • 467
    • 468
    • 469
    • 470
    • 471
    • 472
    • 473
    • 474
    • 475
    • 476
    • 477
    • 478
    • 479
    • 480
    • 481
    • 482
    • 483
    • 484
    • 485
    • 486
    • 487
    • 488
    • 489
    • 490
    • 491
    • 492
    • 493
    • 494
    • 495
    • 496
    • 497
    • 498
    • 499
    • 500
    • 501
    • 502
    • 503
    • 504
    • 505
    • 506
    • 507
    • 508
    • 509
    • 510
    • 511
    • 512
    • 513
    • 514
    • 515
    • 516
    • 517
    • 518
    • 519
    • 520
    • 521
    • 522
    • 523
    • 524
    • 525
    • 526
    • 527
    • 528
    • 529
    • 530
    • 531
    • 532
    • 533
    • 534
    • 535
    • 536
    • 537
    • 538
    • 539
    • 540
    • 541
    • 542
    • 543
    • 544
    • 545
    • 546
    • 547
    • 548
    • 549
    • 550
    • 551
  2. 使用chmod +x 给该脚本执行权限

  3. 将容器中的entrypoint脚本映射为宿主机上刚刚创建的那个脚本。宿主机路径就是刚刚创建的脚本在宿主机上的绝对路径,容器路径:/app/ds/run-document-server.sh

  4. 重新启动onlyoffice容器,日志输出如图表示启动成果,并通过浏览器访问容器映射出来http 80端口,输出如图2标识onlyoffice容器正常启动

    1630589238649
1630589238649
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/573896
推荐阅读
相关标签
  

闽ICP备14008679号