Skip to content

Commit 8f9fe63

Browse files
committed
Merge branch 'dev'
2 parents cf98c00 + 40a9223 commit 8f9fe63

4 files changed

+137
-4
lines changed

docs/en/HealthChecks.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Health Checks
2+
3+
AspNet Zero has an implementation of health checks and health checks UI.
4+
5+
You can enable or disable health checks and health checks UI.
6+
7+
###### Settings
8+
9+
Health checks settings are located in the `appsettings.json` file
10+
11+
```json
12+
"HealthChecks": {
13+
"HealthChecksEnabled": true, //enable/disable all health checks.
14+
"HealthChecksUI": {
15+
"HealthChecksUIEnabled": true, //enable/disable health checks ui
16+
"HealthChecks": [
17+
{
18+
"Name": "MyCompanyName.AbpZeroTemplate.Web.MVC", //your app name
19+
"Uri": "http://localhost:62114/healthz" /* your_project_url/healthz
20+
you should change that url before you publish your project*/
21+
}
22+
],
23+
"EvaluationTimeOnSeconds": 10,
24+
"MinimumSecondsBetweenFailureNotifications": 60,
25+
//"HealthCheckDatabaseConnectionString": "Data Source=[PUT-MY-PATH-HERE]\\healthchecksdb" //-> Optional, default on WebContentRoot,
26+
//for example, if you use azure you may need to set this connection string
27+
}
28+
}
29+
```
30+
31+
32+
33+
> Note: If you enable Health Checks UI, don't forget to change your `healthz` URL before you publish your website.
34+
35+
36+
37+
#### Adding new health check
38+
39+
There are a lot of libraries which you can add to your health check easily. To see a full list of libraries and used package in AspNet Zero, see [https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks). Here are some sample package names:
40+
41+
```
42+
AspNetCore.HealthChecks.System
43+
AspNetCore.HealthChecks.Network
44+
AspNetCore.HealthChecks.SqlServer
45+
...
46+
```
47+
48+
###### Adding your custom health check
49+
50+
To add your own health check, you should create a class inherited from `IHealthCheck`. ( Already implemented health check classes are located under **HealthChecks** folder of `.Application` project.)
51+
52+
```c#
53+
public class MyCustomHealthCheck : IHealthCheck
54+
{
55+
private readonly MyService _myService;
56+
public AbpZeroTemplateDbContextHealthCheck(MyService myService)
57+
{
58+
_myService = myService;
59+
}
60+
61+
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken())
62+
{
63+
if (_myService.CheckSomeThing())
64+
{
65+
return Task.FromResult(HealthCheckResult.Healthy("MyService is healthy."));
66+
}
67+
68+
return Task.FromResult(HealthCheckResult.Unhealthy("MyService is unhealthy."));
69+
}
70+
}
71+
```
72+
73+
In both cases, you should add your health checks to **HealthCheckBuilder**. HealthCheckBuilder is located in `.Web.Core` project. `( .Web.Core -> HealthCheck -> AbpZeroHealthCheck.cs -> AddAbpZeroHealthCheck )` .
74+
75+
```c#
76+
public static class AbpZeroHealthCheck
77+
{
78+
public static IHealthChecksBuilder AddAbpZeroHealthCheck(this IServiceCollection services)
79+
{
80+
var builder = services.AddHealthChecks();
81+
builder.AddCheck<AbpZeroTemplateDbContextHealthCheck>("Database Connection");
82+
builder.AddCheck<AbpZeroTemplateDbContextUsersHealthCheck>("Database Connection with user check");
83+
builder.AddCheck<CacheHealthCheck>("Cache");
84+
85+
// add your other health checks here
86+
// builder.AddCheck<MyCustomHealthCheck>("my health check");
87+
//...
88+
return builder;
89+
}
90+
}
91+
```
92+
93+
After adding your new health check here, you will be able to see its status in JSON and UI automatically.
94+
95+
------
96+
97+
**Endpoints:**
98+
99+
- *MVC project (Only exists in ASP.NET Core & jQuery version)*
100+
101+
Health checks UI endpoint: http://localhost:62114/healthchecks-ui (if it is enabled)
102+
103+
Health checks JSON result endpoint: http://localhost:62114/healthz (if it is enabled)
104+
105+
- *Host project (Available in ASP.NET Core versions but designed for Angular project)*
106+
107+
Health checks UI endpoint: http://localhost:22742/healthchecks-ui (if it is enabled)
108+
109+
Health checks JSON result endpoint: http://localhost:22742/healthz (if it is enabled)
110+
111+
- *Public Website*
112+
113+
Health checks UI endpoint: http://localhost:45776/healthchecks-ui (if it is enabled)
114+
115+
Health checks JSON result endpoint: http://localhost:45776/healthz (if it is enabled)
116+
117+
see also:
118+
https://github.com/xabaril/AspNetCore.Diagnostics.HealthChecks
119+
120+
https://docs.docker.com/engine/reference/builder/#healthcheck
121+
122+
123+
> Note: If you enable health checks, it will create its dbContext. That's why, when you try to create new migration or update database you should also use `-c [YourProjectName]DbContext` command.

docs/en/Infrastructure-Core-Mvc-Bundling-Minifying-Compiling.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Bundling, Minifying and Compiling
22

3-
ASP.NET Zero uses [webpack](https://webpack.js.org/) for bundling & minifying script and style files. ASP.NET Zero also watches style and script files used for bundling and automatically updates bundles when one of the style or script file is changed in development time.
3+
ASP.NET Zero uses [Gulp](https://gulpjs.com/) for bundling & minifying script and style files. ASP.NET Zero also watches style and script files used for bundling and automatically updates only the related bundle when one of the style or script file is changed in development time.
44

55
Bundle definitions are store in **bundles.json** file. Here is a sample screenshot of bundles.json file:
66

@@ -16,7 +16,9 @@ All input sections in **bundles.json **supports wildcard syntax. So, you can inc
1616

1717
By default, ASP.NET Zero has two commands for bundling style and script files "**npm run create-bundles**" and "**npm run build**".
1818

19-
* **npm run create-bundles**: This command is introduced for development time usage. It watches your style and script files for changes and automatically updates bundles. If you modify **bundles.json** file, you need to re-run this command. It also writes output to console about the bundling progress. Script bundles are not minified when using this command.
20-
* **npm run build**: This command is introduced for publishing your app. It doesn't write any output to console and it doesn't watch files for any change. It also minifies script bundles unline "create-bundles" command.
19+
* **npm run create-bundles**: This command is introduced for development time usage. It watches your style and script files for changes and automatically updates bundle(s). If you modify **bundles.json** file, you need to re-run this command. It also writes output to console about the bundling progress. Script and style bundles are not minified when using this command.
20+
* **npm run build**: This command is introduced for publishing your app. It doesn't write any output to console and it doesn't watch files for any change. It also minifies script and style bundles unlike "create-bundles" command.
2121

22-
If you need to make any change about ASP.NET Zero's bundling and minification process, you can modify **webpack.config.js**.
22+
If you need to make any change about ASP.NET Zero's bundling and minification process, you can modify **gulpfile.js** in the root directory of the ***.Web.Mvc** project.
23+
24+
Same approach is used for ***.Web.Public** website project.

docs/en/nav-aspnet-core-angular.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@
168168
{
169169
"text": "Swagger UI",
170170
"path": "Features-Angular-Swagger-UI.md"
171+
},
172+
{
173+
"text": "Healt Checks",
174+
"path": "HealthChecks.md"
171175
}
172176
]
173177
},

docs/en/nav-aspnet-core-mvc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@
158158
{
159159
"text": "Swagger UI",
160160
"path": "Features-Mvc-Core-Swagger-UI.md"
161+
},
162+
{
163+
"text": "Healt Checks",
164+
"path": "HealthChecks.md"
161165
}
162166
]
163167
},

0 commit comments

Comments
 (0)