Skip to content

Commit 20a3357

Browse files
committed
是否引用了星尘SDK的APP。这类APP自带性能上报,无需Deploy上报
1 parent fced733 commit 20a3357

File tree

2 files changed

+44
-19
lines changed

2 files changed

+44
-19
lines changed

Stardust/Deployment/ZipDeploy.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Diagnostics;
2-
using System.Xml.Serialization;
32
using NewLife;
43
using NewLife.Log;
54
using Stardust.Models;

Stardust/Managers/ServiceController.cs

+44-18
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ internal class ServiceController : DisposeBase
6262
/// <summary>事件客户端</summary>
6363
public IEventProvider? EventProvider { get; set; }
6464

65+
/// <summary>是否引用了星尘SDK的APP。这类APP自带性能上报,无需Deploy上报</summary>
66+
public Boolean IsStarApp { get; set; }
67+
6568
private String? _fileName;
6669
private String? _workdir;
6770
private TimerX? _timer;
@@ -148,24 +151,29 @@ public Boolean Start()
148151
case ServiceModes.Multiple:
149152
break;
150153
case ServiceModes.Extract:
151-
WriteLog("解压后不运行,外部主机(如IIS)将托管应用");
152-
Extract(src, args, workDir, false);
153-
Running = true;
154-
return true;
154+
{
155+
WriteLog("解压后不运行,外部主机(如IIS)将托管应用");
156+
var deploy = Extract(src, args, workDir, false);
157+
CheckStarApp(deploy.Shadow, workDir);
158+
Running = true;
159+
return true;
160+
}
155161
case ServiceModes.ExtractAndRun:
156-
WriteLog("解压后在工作目录运行");
157-
var deploy = Extract(src, args, workDir, false);
158-
if (deploy == null) throw new Exception("解压缩失败");
159-
160-
//file ??= deploy.ExecuteFile;
161-
var runfile = deploy.FindExeFile(workDir);
162-
file = runfile?.FullName;
163-
if (file.IsNullOrEmpty()) throw new Exception("无法找到启动文件");
164-
165-
args = deploy.Arguments;
166-
//_fileName = deploy.ExecuteFile;
167-
isZip = false;
168-
break;
162+
{
163+
WriteLog("解压后在工作目录运行");
164+
var deploy = Extract(src, args, workDir, false);
165+
if (deploy == null) throw new Exception("解压缩失败");
166+
167+
//file ??= deploy.ExecuteFile;
168+
var runfile = deploy.FindExeFile(workDir);
169+
file = runfile?.FullName;
170+
if (file.IsNullOrEmpty()) throw new Exception("无法找到启动文件");
171+
172+
args = deploy.Arguments;
173+
//_fileName = deploy.ExecuteFile;
174+
isZip = false;
175+
break;
176+
}
169177
case ServiceModes.RunOnce:
170178
//service.Enable = false;
171179
break;
@@ -181,6 +189,7 @@ public Boolean Start()
181189
if (p == null) return false;
182190

183191
WriteLog("启动成功 PID={0}/{1}", p.Id, p.ProcessName);
192+
CheckStarApp(Path.GetDirectoryName(_fileName), workDir);
184193

185194
if (service.Mode == ServiceModes.RunOnce)
186195
{
@@ -244,6 +253,7 @@ public Boolean Start()
244253
//deploy.Extract(workDir);
245254
// 要解压缩到影子目录,否则可能会把appsettings.json等配置文件覆盖。用完后删除
246255
var shadow = deploy.CreateShadow($"{deploy.Name}-{DateTime.Now:yyyyMMddHHmmss}");
256+
deploy.Shadow = shadow;
247257
deploy.Extract(shadow, CopyModes.ClearBeforeCopy, CopyModes.SkipExists, CopyModes.Overwrite);
248258
try
249259
{
@@ -437,6 +447,22 @@ public Boolean Start()
437447
return p;
438448
}
439449

450+
private void CheckStarApp(String exeDir, String workDir)
451+
{
452+
// 是否引用了星尘SDK的APP。这类APP自带性能上报,无需Deploy上报
453+
IsStarApp = false;
454+
var starFile = exeDir.CombinePath("Stardust.dll").GetFullPath();
455+
if (File.Exists(starFile))
456+
{
457+
IsStarApp = true;
458+
}
459+
else
460+
{
461+
starFile = workDir.CombinePath("Stardust.dll").GetFullPath();
462+
if (File.Exists(starFile)) IsStarApp = true;
463+
}
464+
}
465+
440466
/// <summary>停止应用,等待一会确认进程已退出</summary>
441467
/// <param name="reason"></param>
442468
public void Stop(String reason)
@@ -602,7 +628,7 @@ public Boolean Check()
602628

603629
// 检测并上报性能
604630
p = Process;
605-
if (p != null && EventProvider is StarClient client)
631+
if (p != null && EventProvider is StarClient client && !IsStarApp)
606632
{
607633
if (_appInfo == null || _appInfo.Id != p.Id)
608634
_appInfo = new AppInfo(p) { AppName = inf.Name };

0 commit comments

Comments
 (0)