@@ -62,6 +62,9 @@ internal class ServiceController : DisposeBase
62
62
/// <summary>事件客户端</summary>
63
63
public IEventProvider ? EventProvider { get ; set ; }
64
64
65
+ /// <summary>是否引用了星尘SDK的APP。这类APP自带性能上报,无需Deploy上报</summary>
66
+ public Boolean IsStarApp { get ; set ; }
67
+
65
68
private String ? _fileName ;
66
69
private String ? _workdir ;
67
70
private TimerX ? _timer ;
@@ -148,24 +151,29 @@ public Boolean Start()
148
151
case ServiceModes . Multiple :
149
152
break ;
150
153
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
+ }
155
161
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
+ }
169
177
case ServiceModes . RunOnce :
170
178
//service.Enable = false;
171
179
break ;
@@ -181,6 +189,7 @@ public Boolean Start()
181
189
if ( p == null ) return false ;
182
190
183
191
WriteLog ( "启动成功 PID={0}/{1}" , p . Id , p . ProcessName ) ;
192
+ CheckStarApp ( Path . GetDirectoryName ( _fileName ) , workDir ) ;
184
193
185
194
if ( service . Mode == ServiceModes . RunOnce )
186
195
{
@@ -244,6 +253,7 @@ public Boolean Start()
244
253
//deploy.Extract(workDir);
245
254
// 要解压缩到影子目录,否则可能会把appsettings.json等配置文件覆盖。用完后删除
246
255
var shadow = deploy . CreateShadow ( $ "{ deploy . Name } -{ DateTime . Now : yyyyMMddHHmmss} ") ;
256
+ deploy . Shadow = shadow ;
247
257
deploy . Extract ( shadow , CopyModes . ClearBeforeCopy , CopyModes . SkipExists , CopyModes . Overwrite ) ;
248
258
try
249
259
{
@@ -437,6 +447,22 @@ public Boolean Start()
437
447
return p ;
438
448
}
439
449
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
+
440
466
/// <summary>停止应用,等待一会确认进程已退出</summary>
441
467
/// <param name="reason"></param>
442
468
public void Stop ( String reason )
@@ -602,7 +628,7 @@ public Boolean Check()
602
628
603
629
// 检测并上报性能
604
630
p = Process ;
605
- if ( p != null && EventProvider is StarClient client )
631
+ if ( p != null && EventProvider is StarClient client && ! IsStarApp )
606
632
{
607
633
if ( _appInfo == null || _appInfo . Id != p . Id )
608
634
_appInfo = new AppInfo ( p ) { AppName = inf . Name } ;
0 commit comments