阿和
Published on 2024-12-06 / 37 Visits
1
0

onlyoffice二次开发

环境

nodejs16

python3

postgres/mysql/oracle等 官方支持种类较多详见 server/DocService/sources/databaseConnectors

rabbitmq/activemq 官方只支持这两种

redis 官方有此配置但未在项目内找到实际使用的地方

minio或其他支持s3协议的存储 //不使用s3存储的可以忽略

启动

此处建议使用ubuntu运行,当然也可以在win/mac上运行,如在非ubuntu运行需创建build_tools/tool/linux/packages_complete文件跳过apt的执行

创建启动环境

  1. 克隆仓库 https://github.com/ONLYOFFICE/build_tools //构建及本地启动均需要使用

  2. 进入 build_tools/tools/linux目录

  3. 运行命令 python3 ./automate.py server --develop=1

启动项目

创建构建环境时会自动克隆,也可手动克隆

server 目录

启动 docservice 服务

  1. 进入目录 server/DocService

  2. 执行命令 NODE_CONFIG_DIR=$PWD/../Common/config NODE_ENV=development-mac node ./sources/server.js

启动 converter 服务

  1. 进入目录 server/FileConverter

  2. 执行命令 NODE_CONFIG_DIR=$PWD/../Common/config NODE_ENV=development-mac node ./sources/convertermaster.js

启动 example 服务 // 此处只展示官方示例服务下的nodejs版本,原始仓库 document-server-integration

  1. 进入目录 document-server-integration/web/documentserver-example/nodejs

  2. 执行命令 NODE_CONFIG_DIR=$PWD/config NODE_ENV=development-mac  node ./bin/www

web-apps 目录 //创建构建环境时会自动克隆,也可手动克隆,手机端调试需要进行此步骤

进入 web-apps/vendor/framework7-react 目录

npm run build-word
npm run build-slide
npm run build-cell

构建

全量构建

  1. 进入 build_tools/tools/linux 目录

  2. 执行命令 python3 ./automate.py server --update=0 //如需要同步更新代码移除--update=0

增量构建

构建 docservice

pkg ./ -t node16-linux --options max_old_space_size=4096 -o docservice

构建 converter

pkg ./ -t node16-linux -o converter

构建 example

pkg ./ -t node16-linux -o example

FAQ

NODE_ENV怎么配置

作者此处使用的是mac所以使用 development-mac

增量构建 node16-xxx怎么配置

根据系统cpu环境选择例如

x64使用node16-linux

arm使用node16-arm64

运行过程中提示错误的换行符可直接执行一般只有这两个文件有

vim -c ":set ff=unix" -c ":wq" make.py
vim -c ":set ff=unix" -c ":wq" configure.py

启动后预览白屏 无论是构建包还是开发包

http://documentserver/sdkjs/common/AllFonts.jshttp://documentserver/fonts/* 404

需要先在server同级目录创建fonts文件夹再执行后续shell,如忘记创建目录需先删除 server/FileConverter/font_selection.bin

mkdir fonts
LD_LIBRARY_PATH=${PWD}/server/FileConverter/bin server/tools/allfontsgen \
            --input="${PWD}/core-fonts" \
            --allfonts-web="${PWD}/sdkjs/common/AllFonts.js" \
            --allfonts="${PWD}/server/FileConverter/bin/AllFonts.js" \
            --images="${PWD}/sdkjs/common/Images" \
            --selection="${PWD}/server/FileConverter/bin/font_selection.bin" \
            --output-web='fonts' \
            --use-system="true"
LD_LIBRARY_PATH=${PWD}/server/FileConverter/bin server/tools/allthemesgen \
            --converter-dir="${PWD}/server/FileConverter/bin"\
            --src="${PWD}/sdkjs/slide/themes"\
            --output="${PWD}/sdkjs/common/Images"

example启动后访问提示找不到files文件夹

在运行目录执行

mkdir files

配置项修改

更改 server/Common/config/default.config 或者对应环境的配置文件例如development-mac则寻找server/Common/config/development-mac.json 不存在添加即可

修改端口

services.CoAuthoring.server.port=你需要的端口

文件预览支持内容过小

FileConverter.converter.maxDownloadBytes
FileConverter.converter.inputLimits.zip.uncompressed

修改MQ配置

需要先判断你修改的是rabbitmq/activemq寻找对应的配置并修改

queue.type=mq的类型

修改数据库配置

数据库初始化脚本 server/schema 目录需要根据数据库类型选择

services.CoAuthoring.sql.type=数据库类型
services.CoAuthoring.sql.dbHost=ip/域名
services.CoAuthoring.sql.dbPort=端口
services.CoAuthoring.sql.dbName=数据库名称
services.CoAuthoring.sql.dbUser=数据库账号
services.CoAuthoring.sql.dbPass=数据库密码

修改存储方式

storage.name=你要使用的存储方式支持的有storage-fs/storage-s3
storage.endpoint=s3时传入即可
storage.bucketName=s3时传入即可
storage.accessKeyId=s3时传入即可
storage.secretAccessKey=s3时传入即可

修改认证令牌

services.CoAuthoring.secret.*.string=令牌


Comment