/// <summary>探测并安装星尘代理</summary> /// <param name="url">zip包下载源</param> /// <param name="version">版本号</param> /// <param name="target">目标目录</param> public static Task ProbeAsync(String url = null, String version = null, String target = null) { return(TaskEx.Run(() => { var client = new LocalStarClient(); client.ProbeAndInstall(url, version, target); })); }
private void Init() { Local = new LocalStarClient(); // 读取本地appsetting if (Server.IsNullOrEmpty()) { var json = new JsonConfigProvider { FileName = "appsettings.json" }; json.LoadAll(); Server = json["StarServer"]; } if (Server.IsNullOrEmpty()) { try { var inf = Local.GetInfo(); var server = inf?.Server; if (!server.IsNullOrEmpty()) { Server = server; XTrace.WriteLine("星尘探测:{0}", server); } } catch (Exception ex) { XTrace.WriteException(ex); } } // 如果探测不到本地应用,则使用配置 var set = Setting.Current; if (Server.IsNullOrEmpty()) { Server = set.Server; } if (AppId.IsNullOrEmpty()) { AppId = set.AppKey; } if (Secret.IsNullOrEmpty()) { Secret = set.Secret; } if (AppId.IsNullOrEmpty()) { AppId = AssemblyX.Entry.Name; } XTrace.WriteLine("星尘分布式服务 Server={0} AppId={1}", Server, AppId); }
private void Init() { Local = new LocalStarClient(); // 读取本地appsetting if (Server.IsNullOrEmpty() && File.Exists("appsettings.Development.json".GetFullPath())) { using var json = new JsonConfigProvider { FileName = "appsettings.Development.json" }; json.LoadAll(); Server = json["StarServer"]; } if (Server.IsNullOrEmpty() && File.Exists("appsettings.json".GetFullPath())) { using var json = new JsonConfigProvider { FileName = "appsettings.json" }; json.LoadAll(); Server = json["StarServer"]; } if (!Server.IsNullOrEmpty() && Local.Server.IsNullOrEmpty()) { Local.Server = Server; } try { var inf = Local.GetInfo(); var server = inf?.Server; if (!server.IsNullOrEmpty()) { if (Server.IsNullOrEmpty()) { Server = server; } XTrace.WriteLine("星尘探测:{0}", server); } } catch (Exception ex) { XTrace.Log.Error("星尘探测失败!{0}", ex.Message); } // 如果探测不到本地应用,则使用配置 var set = StarSetting.Current; if (Server.IsNullOrEmpty()) { Server = set.Server; } if (AppId.IsNullOrEmpty()) { AppId = set.AppKey; } if (Secret.IsNullOrEmpty()) { Secret = set.Secret; } try { var executing = AssemblyX.Create(Assembly.GetExecutingAssembly()); var asm = AssemblyX.Entry ?? executing; if (asm != null) { if (AppId.IsNullOrEmpty()) { AppId = asm.Name; } if (AppName.IsNullOrEmpty()) { AppName = asm.Title; } } ClientId = $"{NetHelper.MyIP()}@{Process.GetCurrentProcess().Id}"; } catch { } XTrace.WriteLine("星尘分布式服务 Server={0} AppId={1}", Server, AppId); var ioc = ObjectContainer.Current; ioc.AddSingleton(this); ioc.AddSingleton(p => Tracer); ioc.AddSingleton(p => Config); ioc.AddSingleton(p => Service); }