FlowCore® 9.0 - 银河麒麟使用 Systemd 托管
重要
FlowCore® 包含自托管 Kestrel Web 服务器,Kestrel 可以单独使用,也可以与反向代理服务器一起使用。FlowCore® 应用程序 runroot 程序集文件夹中包含应用程序目录结构。
FlowCore® 在银河麒麟高级服务器操作系统上从 runroot/FlowCore.dll 文件启动。
本文教程演示命令适用于 银河麒麟高级服务器操作系统 V11, V10。
(1)部署 FlowCore 程序文件
1.1 下载 FlowCore 程序包
https://www.paicore.com/zh/downloads
Linux 命令
sudo unzip FlowCore-XXX.zip
解开 FlowCore 程序包,移动 approot 到目标部署路径,例如 /flowcore。
Linux 命令
sudo mv approot /flowcore
1.2 安装字体
安装字体管理工具适用于 银河麒麟 V11, V10Linux 命令sudo dnf -y install fontconfig
复制 /flowcore/fonts 文件夹下的全部字体文件到 /usr/share/fonts。
Linux 命令
sudo cp -rf /flowcore/fonts/* /usr/share/fonts
更新字体
Linux 命令
sudo fc-cache -f -v
查看字体
Linux 命令
sudo fc-list
1.3 安装依赖程序
暂无。1.4 设置 FlowCore 目录结构的文件系统权限
FlowCore® 9.0 目录结构的文件系统权限列表如下。
目录/文件
文件系统权限
chmod 权限
用途
/fonts
只读
r--
字体文件
/license
读取、写入
rw-
存储许可证文件
/runroot
读取、执行
r-x
应用程序目录结构
/storagePath
读取、写入
rw-
存储路径
/temp
读取、写入
rw-
临时文件夹
certarchive.json
只读
r--
数字存档证书配置
cloudstorage.json
只读
r--
云存储配置
database.json
只读
r--
配置数据库连接
配置文件系统权限,依次执行下列 chmod 命令。
Linux 命令(依次执行)
sudo chmod -R 444 /flowcore/fonts sudo chmod -R 666 /flowcore/license sudo chmod -R 555 /flowcore/runroot sudo chmod -R 666 /flowcore/storagePath sudo chmod -R 666 /flowcore/temp sudo chmod 444 /flowcore/certarchive.json sudo chmod 444 /flowcore/cloudstorage.json sudo chmod 444 /flowcore/database.json
(2)创建数据库结构
FlowCore 程序包 database-sql-statements 文件夹下,包含创建数据库结构的 SQL 语句。
FlowCore® 9.0 支持数据库:Microsoft SQL Server、PostgreSQL、KingbaseES 和 MySQL。
lMicrosoft SQL Server 2025, 2022, 2019, 2017, 2016
lMicrosoft SQL Server Express 2025, 2022, 2019, 2017, 2016
lPostgreSQL 19, 18, 17, 16, 15, 14, 13, 12
lKingbaseES V9
lMySQL 8.0+
lMicrosoft SQL Server Express 2025, 2022, 2019, 2017, 2016
lPostgreSQL 19, 18, 17, 16, 15, 14, 13, 12
lKingbaseES V9
lMySQL 8.0+
2.1 创建 Microsoft SQL Server 数据库结构。
使用 SQL Server 管理器,新建数据库 FlowCore(数据库名称可以自定义)。
使用 SQL Server 管理器,选择数据库 >> 属性 >> 选项,确认数据库排序规则为 Chinese_PRC_CI_AS(简体中文)。
SQL Server 数据库 简体中文的排序规则
使用 SQL Server 管理器,选择数据库 >> 属性 >> 选项,确认数据库排序规则为 Chinese_PRC_CI_AS(简体中文)。
使用 SQL Server 查询分析器,创建 FlowCore 数据库结构(依次执行 SQL 语句 microsoft-sqlserver....sql)。
| 1、系统核心数据结构 | 2、基本的演示流程(演示流程和表单模板) | 3、更多的演示流程(更多流程和表单模板) |
|---|---|---|
| microsoft-sqlserver_core.sql | microsoft-sqlserver_demo.sql | microsoft-sqlserver_workflow_sample.sql |
2.2 创建 PostgreSQL、KingbaseES 数据库结构。
使用 PostgreSQL、KingbaseES 管理工具,创建 FlowCore 数据库结构(依次执行 SQL 语句 postgresql....sql)。
| 1、系统核心数据结构 | 2、基本的演示流程(演示流程和表单模板) | 3、更多的演示流程(更多流程和表单模板) |
|---|---|---|
| postgresql_core.sql | postgresql_demo.sql | postgresql_workflow_sample.sql |
2.3 创建 MySQL 数据库结构。
使用 MySQL 管理工具,创建 FlowCore 数据库结构(依次执行 SQL 语句 mysql....sql)。
| 1、系统核心数据结构 | 2、基本的演示流程(演示流程和表单模板) | 3、更多的演示流程(更多流程和表单模板) |
|---|---|---|
| mysql_core.sql | mysql_demo.sql | mysql_workflow_sample.sql |
(3)配置数据库连接
编辑 database.json 配置数据库 ConnectionStrings 连接信息。
DatabaseType 配置数据库类型:可以设置为 "SQLServer" 、"PostgreSQL"、"KingbaseES" 、"MySQL"。
DatabaseType 配置数据库类型:可以设置为 "SQLServer" 、"PostgreSQL"、"KingbaseES" 、"MySQL"。
重要:在 json 配置文件中,使用两个 \\ 代表一个 \。
例如:使用 PostgreSQL 数据库,DatabaseType 设置为"PostgreSQL"。
{
"DatabaseType": "PostgreSQL",
"ConnectionStrings": {
"SQLServer": "database=FlowCore;Data Source=localhost;User ID=sa;password=YourPassword;Connect Timeout=60;TrustServerCertificate=true",
"PostgreSQL": "Database=FlowCore;Host=localhost;Port=5432;Username=postgres;Password=YourPassword",
"KingbaseES": "Database=FlowCore;Host=localhost;Port=54321;Username=system;Password=YourPassword",
"MySQL": "Database=FlowCore;Server=localhost;Port=3306;User ID=root;Password=YourPassword"
}
}
(4)在 Linux 上安装 .NET 10 SDK(ASP.NET Core 10)
适用于 银河麒麟 V11, V10
使用脚本安装
查看 .NET 环境信息Linux 命令(安装 .NET 10 SDK)wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh chmod +x ./dotnet-install.sh ./dotnet-install.sh --channel 10.0Linux 命令(安装所有依赖项)设置系统范围的环境变量sudo dnf install glibc libgcc ca-certificates openssl-libs libstdc++ libicu tzdata krb5-libsLinux 命令sudo vim ~/.bashrc在 .bashrc 中添加以下内容,保存退出(重启系统生效)。export DOTNET_ROOT=/root/.dotnet export PATH=$PATH:/root/.dotnet:/root/.dotnet/toolsLinux 命令,设置环境变量、立刻生效。export DOTNET_ROOT=/root/.dotnet export PATH=$PATH:/root/.dotnet:/root/.dotnet/tools
Linux 命令
dotnet --info dotnet --list-sdks dotnet --list-runtimes dotnet --version
(5)测试、验证启动 Kestrel Web 服务器
5.1 配置 Kestrel 绑定本机端口。
打开 runroot/appsettings.json,Kestrel 默认绑定本机地址和端口
localhost 等于 127.0.0.1/::1,使用 Kestrel 绑定本机地址和端口,可以与反向代理一起使用。
你可以自定义 Kestrel 绑定的端口(建议端口范围 5000-60000),只要该端口没有占用。
5.2 在 Linux 命令行中启动 Kestrel 服务器,验证 Kestrel 是否正常工作。
打开 runroot/appsettings.json,Kestrel 默认绑定本机地址和端口
http://localhost:5000。localhost 等于 127.0.0.1/::1,使用 Kestrel 绑定本机地址和端口,可以与反向代理一起使用。
你可以自定义 Kestrel 绑定的端口(建议端口范围 5000-60000),只要该端口没有占用。
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://localhost:5000"
}
}
}
5.2 在 Linux 命令行中启动 Kestrel 服务器,验证 Kestrel 是否正常工作。
Linux 命令
dotnet /flowcore/runroot/FlowCore.dll
(6)使用 Systemd 托管 FlowCore
Systemd 是 Linux 系统工具,用来启动守护进程,已成为大多数 Linux 发行版的标准配置。
适用于 银河麒麟 V11, V10
使用 vim 编辑 flowcore2.service,把部署路径 /flowcore 修改为实际的部署路径。
Linux 命令
sudo vim /flowcore/runroot/flowcore2.service
请根据你的实际配置,修改标记为紫色或红色的部分。
[Unit] Description=FlowCore [Service] WorkingDirectory=/flowcore/runroot ExecStart=/root/.dotnet/dotnet /flowcore/runroot/FlowCore.dll Restart=always RestartSec=10 SyslogIdentifier=flowcore User=root Environment=DOTNET_ROOT=/root/.dotnet TimeoutStopSec=30 [Install] WantedBy=multi-user.target
flowcore2.service 到 /etc/systemd/system。
Linux 命令
sudo cp /flowcore/runroot/flowcore2.service /etc/systemd/system/flowcore.service
Systemd 服务控制
安装服务
启动服务
重新加载配置(适用于修改 .service 服务配置文件之后)
重启服务
停止服务
查看服务状态
安装服务
Linux 命令
sudo systemctl enable /etc/systemd/system/flowcore.service
启动服务
Linux 命令
sudo systemctl start flowcore
重新加载配置(适用于修改 .service 服务配置文件之后)
Linux 命令
sudo systemctl daemon-reload
重启服务
Linux 命令
sudo systemctl restart flowcore
停止服务
Linux 命令
sudo systemctl stop flowcore
查看服务状态
Linux 命令
sudo systemctl status flowcore
(7)配置 Kestrel Web 服务器、独立提供服务
本章节配置 Kestrel Web 服务器,绑定域名和 SSL 证书,独立提供服务。
在验证 HTTPS 访问成功后,启用 HttpsRedirection 跳转。
7.1 使用 vim 编辑 appsettings.json 配置 Kestrel Web 服务器。
Kestrel 绑定主机和端口
7.2 修改 appsettings.json 后,重新启动 Kestrel Web 服务器。
7.3 验证测试 HTTP 和 HTTPS 配置成功。
7.4 将 HTTP 重定向到 HTTPS
使用 vim 编辑 runroot/appsettings.json,修改为 "HttpsRedirection": true。 重启 flowcore 服务。
在验证 HTTPS 访问成功后,启用 HttpsRedirection 跳转。
7.1 使用 vim 编辑 appsettings.json 配置 Kestrel Web 服务器。
Linux 命令
sudo vim /flowcore/runroot/appsettings.json
Kestrel 绑定主机和端口
http://localhost:5000(http 监听本机网卡回环地址:5000 端口,只能在本机访问) http://*:5000(http 监听所有 IP 地址:5000 端口) http://sample.paicore.com(http 监听本机所有 IP 地址:80 端口) https://sample.paicore.com(https 监听本机所有 IP 地址:443 端口)appsettings.json 配置如下:
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://sample.paicore.com"
},
"Https": {
"Url": "https://sample.paicore.com",
"Certificate": {
"Path": "/flowcore/sample-ssl.pfx",
"Password": "Your Password"
}
}
}
},
"EnforcingSSL": {
"HttpsRedirection": false,
"UseHsts": false
}
7.2 修改 appsettings.json 后,重新启动 Kestrel Web 服务器。
Linux 命令
sudo systemctl restart flowcore
7.3 验证测试 HTTP 和 HTTPS 配置成功。
Linux 命令
curl http://sample.paicore.com
Linux 命令
curl -4 https://sample.paicore.com
7.4 将 HTTP 重定向到 HTTPS
使用 vim 编辑 runroot/appsettings.json,修改为 "HttpsRedirection": true。 重启 flowcore 服务。
Linux 命令
sudo systemctl restart flowcore