Jc.ServerHealth
1.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Jc.ServerHealth --version 1.0.3
NuGet\Install-Package Jc.ServerHealth -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jc.ServerHealth" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jc.ServerHealth --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jc.ServerHealth, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Jc.ServerHealth as a Cake Addin #addin nuget:?package=Jc.ServerHealth&version=1.0.3 // Install Jc.ServerHealth as a Cake Tool #tool nuget:?package=Jc.ServerHealth&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Jc.ServerHealth
WebApi 健康检查接口
引用这个模块后不需要做其他对事;
会多出一个接口 /api/gethealth
注意:使用此模块 在某些条件下 swagger将无法正常工作
请求方式:
Get&Post
返回值:
{
"Code": "200",
"Message": "ok",
"Time": "时间戳",
"Version": "版本号"
}
在jenkins中使用
Shell脚本思路
#!/bin/bash
# 声明接口地址
url=http://{ip}:{port}/api/gethealth
# 添加服务状态检查方法
checkHealth(){
result=$(curl -s ${url} | grep "UP")
if [ "$result" != "" ]; then
return "1"
else
return "0"
fi
}
checkHealth
# 结果判断打印
if [ $? -eq "1" ];then
echo "server is running"
else
echo "server is wrong"
fi
明确健康检查接口及其接口返回结构
执行 grep 搜索关键标识结果的词
判断是否存在,做对应的逻辑输出和流程
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Microsoft.AspNetCore.Mvc.ApiExplorer (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.