Jc.ServerHealth 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package Jc.ServerHealth --version 1.0.5
NuGet\Install-Package Jc.ServerHealth -Version 1.0.5
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.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jc.ServerHealth --version 1.0.5
#r "nuget: Jc.ServerHealth, 1.0.5"
#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.5

// Install Jc.ServerHealth as a Cake Tool
#tool nuget:?package=Jc.ServerHealth&version=1.0.5

Jc.ServerHealth

WebApi 健康检查接口

引用这个模块后不需要做其他对事; 会多出两个接口

注意:使用此模块 在某些条件下 swagger将无法正常工作

第一个:

/api/gethealth

请求方式:

Get&Post

返回值:
{
	"Code": "200",
	"Message": "ok",
	"Time": "时间戳",
	"Version": "版本号"
}

第二个

/api/get

返回值
ok
在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 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. 
.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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.9 212 11/30/2023
1.0.8 145 10/20/2023
1.0.7 139 7/14/2023
1.0.6 207 3/14/2023
1.0.5 218 3/13/2023
1.0.4 208 3/7/2023
1.0.3 207 3/7/2023