NET
https://awesomeopensource.com/project/NewLifeX/AntJob
https://newlifex.com/blood/antjob
http://ant.newlifex.com
AntJob********
2008//
20161200Redis>2T20192019
AntJob
AntJob 1. 1.
https://github.com/NewLifeX/AntJob/tree/master/Samples/HisAgent
.net core 3.1nuget AntJobScheduler
using System;
using AntJob;
using AntJob.Providers;
using NewLife.Log;
namespace HisAgent
{
class Program
{
static void Main(string[] args)
{
XTrace.UseConsole();
var set = AntSetting.Current;
//
var sc = new Scheduler();
//
sc.Provider = new NetworkJobProvider
{
Server = set.Server,
AppID = set.AppID,
Secret = set.Secret,
};
//
sc.Handlers.Add(new HelloJob());
//
sc.Start();
Console.WriteLine("OK!");
Console.ReadKey();
}
}
}
using System;
using AntJob;
namespace HisAgent
{
internal class HelloJob : Handler
{
public HelloJob()
{
// 10
var job = Job;
job.Start = DateTime.Today;
job.Step = 10;
}
protected override Int32 Execute(JobContext ctx)
{
//
var time = ctx.Task.Start;
WriteLog("{0}", time);
//
return 1;
}
}
}
HandlerExecute
ctx.TaskStart
Step
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyVersion>1.0.*</AssemblyVersion>
<Deterministic>false</Deterministic>
<OutputPath>..\..\Bin\HisAgent</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
tcp://127.0.0.1:9999 tcp://ant.newlifex.com:9999
/// <summary></summary>
[Config("Ant")]
public class AntSetting : Config<AntSetting>
{
#region
/// <summary>false</summary>
[Description("false")]
public Boolean Debug { get; set; }
/// <summary></summary>
[Description("")]
public String Server { get; set; } = "tcp://127.0.0.1:9999,tcp://ant.newlifex.com:9999";
/// <summary></summary>
[Description("")]
public String AppID { get; set; }
/// <summary></summary>
[Description("")]
public String Secret { get; set; }
#endregion
#region
/// <summary></summary>
protected override void OnLoaded()
{
if (AppID.IsNullOrEmpty())
{
var asm = Assembly.GetEntryAssembly();
if (asm != null) AppID = asm.GetName().Name;
}
base.OnLoaded();
}
#endregion
}
MainServer+AppID+Secret
AppIDSecret
AutoRegistry
21:33:08.470 1 N - [AntJob.Providers.NetworkJobProvider][1]5
21:33:08.471 1 N - HelloJob False 2020-04-09 00:00:00, 0001-01-01 00:00:00 Offset=15 Step=10 MaxTask=8
21:33:08.587 5 Y Job HelloJob
21:33:09.467 7 Y T [180.174.185.180:53926]X3
HelloJobsc.Handlers.Add(new HelloJob())``
HelloJobFalseweb
xxxPeersHisAgentPeers
HistAgentwebhttp://ant.newlifex.com/
HelloJobHisAgentHelloJob
00:00:00 10
HisAgent10
HelloJob
110
HisAgent
HisAgent
HelloJob
IJob
->: app
note over : app/secret
-->>:
Web->:
Web->:
->:
->:
note over :
-->:
note over Web:
->:
-->:
->:
->:
-->>2:
2->:
2->:
3->:
4->:
Web-->:
net6.0/netstandard2.12021.1225net5.0/netstandard2.0/net4.5/net4.0/net2.0
.NET6 | ||||
---|---|---|---|---|
NewLife.Core | 2002 | RPCAPM | ||
NewLife.XCode | 2005 | MySQL/SQLite/SqlServer/Oracle/TDengine/ | ||
NewLife.Net | 2005 | 2266tps400Tcp | ||
NewLife.Cube | 2010 | SSOOAuth100 | ||
NewLife.Agent | 2008 | WindowsLinuxSystemd | ||
NewLife.Zero | 2020 | ZeroWebWebApi | ||
NewLife.Redis | 2017 | Redis | ||
NewLife.RocketMQ | 2018 | Apache RocketMQ | ||
NewLife.MQTT | 2019 | |||
NewLife.IoT | 2022 | IoT | ||
NewLife.LoRa | 2016 | LoRaWAN | ||
AntJob | 2019 | / | ||
Stardust | 2018 | APM | ||
CrazyCoder | 2006 | Modbus | ||
XProxy | 2005 | NATHttp | ||
SmartOS | 2014 | C++11 | ARM Cortex-M | |
GitCandy | 2015 | Git | ||
NewLife.A2 | 2019 | .NET | ||
NewLife.IoT | 2020 | |||
NewLife.UWB | 2020 |
NewLife2002
NewLifeNuget60
NewLife.XCodeAntJobStardustNewLife.RedisNewLife.IoT
IT
2002202010
https://newlifex.com
https://github.com/newlifex
QQ1600800/1600838