You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
未与业务程序直接集成到一起,使用`.NET6`的`Kestrel`托管的方式来单独部署的`Hangfire`,持久化采用`MS SQLSERVER`,关于定时任务的操作使用`Hangfire.HttpJob`插件来直接在`Hangfire Dashboard UI`上操作。
|
|
|
|
|
|
|
|
|
|
## 部署
|
|
|
|
|
|
|
|
|
|
### 环境
|
|
|
|
|
|
|
|
|
|
1. .NET 6 Runtime
|
|
|
|
|
2. MS SQLSERVER
|
|
|
|
|
|
|
|
|
|
### 步骤
|
|
|
|
|
|
|
|
|
|
1.先到数据库新建一个空数据库,例如叫`HangfireDB`。
|
|
|
|
|
|
|
|
|
|
2.修改项目的`appsetting.json`的`ConnectionStrings`数据库连接字符串,使其指向刚创建的空数据库。
|
|
|
|
|
|
|
|
|
|
3.打包该项目,以文件的形式发布至服务器。
|
|
|
|
|
|
|
|
|
|
4.双击`Hangfire.Job.exe`运行即可,默认端口8093,可以根据需要修改`appsetting.json`的`Kestrel`节点即可,运行后会自动在刚才创建的空数据库(`HangfireDB`)中创建相关所需表。
|
|
|
|
|
|
|
|
|
|
5.打开Hangfire Dashboard UI`http://localhost:8093/hangfire`即可查看任务执行情况。
|
|
|
|
|
|
|
|
|
|
## 操作
|
|
|
|
|
|
|
|
|
|
`Hangfire`官方提供的面板可以查看任务的执行情况,但是不提供添加、查看、修改等操作任务的界面,使用三方插件`Hangfire.HttpJob`后会提供一个简单的任务操作界面,使其可以在界面上简单配置http任务,相关参数详见文档。
|
|
|
|
|
|
|
|
|
|
## 文档
|
|
|
|
|
|
|
|
|
|
- [Hangfire官方文档](https://docs.hangfire.io/en/latest/getting-started/aspnet-applications.html)
|
|
|
|
|
- [Hangfire.HttpJob](https://github.com/yuzd/Hangfire.HttpJob/wiki/01.%E5%A6%82%E4%BD%95%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E8%AE%A1%E5%88%92httpjob%E4%BB%BB%E5%8A%A1)
|