|
|
using Microsoft.AspNetCore;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using Serilog;
|
|
|
using System;
|
|
|
using System.IO;
|
|
|
using System.Text;
|
|
|
|
|
|
namespace IoTNode
|
|
|
{
|
|
|
public class Program
|
|
|
{
|
|
|
public static void Main(string[] args)
|
|
|
{
|
|
|
Console.OutputEncoding = Encoding.UTF8;
|
|
|
var config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
|
|
|
.AddJsonFile("appsettings.json", optional: true)
|
|
|
.Build();
|
|
|
WebHost.CreateDefaultBuilder(args)
|
|
|
.UseConfiguration(config)
|
|
|
.ConfigureLogging((c, o) =>
|
|
|
{
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
|
.ReadFrom.Configuration(config)
|
|
|
.WriteTo.Console()
|
|
|
.WriteTo.File("logs/log.txt", rollOnFileSizeLimit: true, fileSizeLimitBytes: 100 * 1024 * 1024, rollingInterval: RollingInterval.Infinite)
|
|
|
.CreateLogger();
|
|
|
o.AddSerilog();
|
|
|
})
|
|
|
.UseStartup<Startup>()
|
|
|
.Build()
|
|
|
.Run();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/*
|
|
|
1.程序
|
|
|
(1)检查升级程序是否需要升级
|
|
|
(2)升级升级程序
|
|
|
(3)下载升级程序,检查checksum
|
|
|
(4)备份现有升级程序
|
|
|
(5)关闭升级程序
|
|
|
(6)升级升级程序:ui, db->start
|
|
|
(7)升级失败,还原升级程序,写入失败信息到程序存储
|
|
|
(8)升级成功,启动升级程序
|
|
|
(9)发送升级命令给升级程序
|
|
|
2.升级程序
|
|
|
(1)检查程序是否需要升级
|
|
|
(2)下载新程序,检查checksum
|
|
|
(3)备份现有程序
|
|
|
(4)升级程序
|
|
|
(5)失败还原
|
|
|
(6)成功启动
|
|
|
*/
|
|
|
/*
|
|
|
/// <summary>
|
|
|
/// <PackageReference Include="Kveer.XmlRPC" Version="1.1.1" />
|
|
|
/// http://www.xml-rpc.net/faq/xmlrpcnetfaq-2-5-0.html#2.5
|
|
|
/// http://supervisord.org/api.html
|
|
|
/// </summary>
|
|
|
[XmlRpcUrl("http://iot.edusoa.com:8003/RPC2")]
|
|
|
public interface ISupervisor : IXmlRpcProxy
|
|
|
{
|
|
|
[XmlRpcMethod("system.listMethods")]
|
|
|
string SystemListMethods(int stateNumber);
|
|
|
}
|
|
|
|
|
|
class Program
|
|
|
{
|
|
|
static void Main(string[] args)
|
|
|
{
|
|
|
var proxy = XmlRpcProxyGen.Create<ISupervisor>();
|
|
|
proxy.Credentials = new NetworkCredential("usr", "pwd");
|
|
|
var list = proxy.SystemListMethods();
|
|
|
foreach (var item in list)
|
|
|
{
|
|
|
Console.WriteLine(item);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
*/ |