.net core项目部署至信创环境

1.打包

PowerShell中,输入命令

bash 复制代码
dotnet publish -c Release -r linux-x64 --self-contained false

使用压缩软件打包为zip,并上传至服务指定目录

2.解压

bash 复制代码
unzip QServices.zip

3.启动 .net core API

进入项目目录

修改服务器端数据库连接字符串

执行

bash 复制代码
dotnet QServices.dll --urls http://0.0.0.0:8053

4.配置开机自动启动

4.1 创建Systemd服务文件

bash 复制代码
sudo vi /etc/systemd/system/QService.service

写入配置

bash 复制代码
[Unit]
Description=QServices .NET Core API
After=network.target

[Service]
WorkingDirectory=/opt/qapp/QServices
ExecStart=/usr/share/dotnet/dotnet /opt/qapp/QServices/GRSH.Qnu.Service.dll --urls=http://0.0.0.0:8053
Restart=always
RestartSec=10
SyslogIdentifier=QService
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

4.2 重启

bash 复制代码
sudo systemctl daemon-reload

4.3 启动服务

bash 复制代码
sudo systemctl start QService

4.4 设置开机自动启动

bash 复制代码
sudo systemctl enable QService

4.5 查看服务运行状态

bash 复制代码
systemctl status QService

4.6 查看日志

查看最近日志

bash 复制代码
journalctl -u QService

查看实时日志,该命令主要用于排查错误

bash 复制代码
journalctl -u QService -f

5.其他

启动服务

bash 复制代码
systemctl start QService

停止服务

bash 复制代码
systemctl stop QService

重启服务

bash 复制代码
systemctl restart QService

查看状态

bash 复制代码
systemctl status QService

查看是否开机启动

cs 复制代码
systemctl list-unit-files | grep QService
相关推荐
1-1=01 小时前
.NET Core 内存管理
.net·.netcore
1-1=08 小时前
.NET Core 配置与选项
.net·.netcore·1024程序员节
淡海水2 天前
08-02-优化-LINQ与函数式编程的GC代价
unity·c#·.netcore·linq·gc
淡海水3 天前
07-06-源码-.NET Core GC的极致优化技术
unity·架构·c#·.netcore·gc·1024程序员节
淡海水4 天前
07-02-源码-.NET Core GC分配路径
算法·unity·c#·.netcore·gc·1024程序员节
淡海水4 天前
07-04-源码-.NET Core GC清扫与压缩
unity·架构·c#·.netcore·gc·1024程序员节
1-1=05 天前
.NET Core 本地化 (L10n)
.net·.netcore
1-1=05 天前
.NET Core 健康检查
.net·.netcore·1024程序员节
淡海水5 天前
07-03-源码-.NET Core GC标记与扫描
unity·c#·.netcore·gc
csdn_aspnet5 天前
.NETCore SqlSuagr 根据 mysql 数据表按顺序生成简单编号
mysql·.netcore·sqlsugar·1024程序员节·sequence·.net8·编号