packServer/desktop/YuncangTrace.LocalService.csproj
liufumingren 49681b7bdd 加固日志:写入不再静默丢失 + 心跳每 5 分钟落一行
上次现场排查发现 16:28-22:47 六小时日志全丢,但同一时间上报和
scan-records.json 都正常 —— 原因是 File.AppendAllText 按 FileShare.Read
打开,日志文件被别的程序占着时每次都抛 IOException,又被 catch{} 吞掉。

- AppLog 改用 FileShare.ReadWrite|Delete 打开并重试一次,仍失败则累加丢弃计数
- agent-status.json 暴露 LogDropped / LogLastDroppedAt,现场能看出日志是否完整
- 心跳日志改为每 5 分钟一行(含在线通道数、待上传条数),持续失败也每 5 分钟补一行
- 通道断开日志沿用原有节流(前 3 次 + 每 10 次),配合心跳行可定位断点

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-22 03:12:14 +08:00

118 lines
6.9 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!-- WPF 鍙兘璺戝湪 Windows 涓婏紱net8.0-windows 鏄綋鍓?LTS -->
<TargetFramework>net8.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<!-- 鎵樼洏鍥炬爣鐢?WinForms 鐨?NotifyIcon锛圵PF 娌℃湁鍐呯疆鎵樼洏锛?-->
<UseWindowsForms>true</UseWindowsForms>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<!--
鈿狅笍 蹇呴』鍏虫帀闅愬紡 using锛歐PF 涓?WinForms 鍚屾椂寮€鍚椂锛屼袱杈圭殑闅愬紡鍛藉悕绌洪棿浼氳
MessageBox / Application / Clipboard / Point 绛夌被鍨嬩骇鐢熸涔夛紙缂栬瘧涓嶈繃锛夈€?
鍚勬枃浠堕噷鏄惧紡 using 鑷繁闇€瑕佺殑鍛藉悕绌洪棿銆?
-->
<ImplicitUsings>disable</ImplicitUsings>
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
<!-- 浜х墿鍚?绋嬪簭闆嗗悕锛堝畨瑁呭寘閲?exe 灏卞彨杩欎釜锛?-->
<AssemblyName>YuncangTrace.LocalService</AssemblyName>
<RootNamespace>YuncangTrace.LocalService</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<!--
WFAC010锛歐inForms 鍒嗘瀽鍣ㄥ缓璁妸楂?DPI 浠?manifest 鎸埌 ApplicationHighDpiMode銆?
浣嗘湰绋嬪簭鏄?WPF 瀹夸富锛堣蛋鐨勬槸 WPF 鐨?App.Run锛屼笉浼氳皟 WinForms 鐨?ApplicationConfiguration锛夛紝
WinForms 鍙敤鏉ユ斁鎵樼洏鍥炬爣 鈥斺€?閭f潯寤鸿鍦ㄨ繖閲屼笉鐢熸晥锛孌PI 鍙兘鐢?manifest 鐨?PerMonitorV2 鍐冲畾銆?
-->
<NoWarn>$(NoWarn);WFAC010</NoWarn>
<!--
鐜閰嶇疆锛堝拰鍓嶇 VITE_BACKEND 涓€涓€濊矾锛氱敱鏋勫缓鍐冲畾锛屼笉闈犵敤鎴锋墜濉級
Debug 锛欰ppEnvironment=Development锛岄粯璁ゅ悗绔?http://127.0.0.1:7300锛? 鍓嶇 dev 浠g悊鐨勫湴鍧€锛?
Release 锛欰ppEnvironment=Production 锛岄粯璁ゅ悗绔敱 -p:ServerBaseUrl=https://姝e紡鍩熷悕 瑕嗙洊
杩愯鏃惰鐩栦紭鍏堢骇锛氬懡浠よ server 鍙傛暟 &gt; YUNCANG_SERVER 鐜鍙橀噺 &gt; 杩欓噷娉ㄥ叆鐨勯粯璁ゅ€笺€?
-->
<AppEnvironment Condition="'$(Configuration)' == 'Debug'">Development</AppEnvironment>
<AppEnvironment Condition="'$(Configuration)' == 'Release'">Production</AppEnvironment>
<ServerBaseUrl Condition="'$(Configuration)' == 'Debug' and '$(ServerBaseUrl)' == ''">http://127.0.0.1:7300</ServerBaseUrl>
<ServerBaseUrl Condition="'$(Configuration)' == 'Release' and '$(ServerBaseUrl)' == ''">https://packs.example.com</ServerBaseUrl>
<Version>1.0.107</Version>
<Product>浜戜粨瑙嗛婧簮杞欢</Product>
<Company>浜戜粨</Company>
<AssemblyTitle>浜戜粨瑙嗛婧簮杞欢锛堟湰鏈烘湇鍔★級</AssemblyTitle>
<NeutralLanguage>zh-CN</NeutralLanguage>
<!--
鍚屼竴涓?exe 涓夌韬唤锛氭闈㈢ / Windows 鏈嶅姟锛坰ervice 鍙傛暟锛? 鎻愭潈 helper锛坅gent-control 鍙傛暟锛夈€?
鍏ュ彛鍦?Program.cs锛涗笉鍐?StartupObject 鐨勮瘽 WPF 鑷姩鐢熸垚鐨?Main 浼氬拰瀹冨啿绐侊紙CS0017锛夈€?
-->
<StartupObject>YuncangTrace.LocalService.Program</StartupObject>
</PropertyGroup>
<!-- 鎶婄幆澧冨啓杩涚▼搴忛泦锛圫ervices/BuildInfo.cs 杩愯鏃惰鍑烘潵锛?-->
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>AppEnvironment</_Parameter1>
<_Parameter2>$(AppEnvironment)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>ServerBaseUrl</_Parameter1>
<_Parameter2>$(ServerBaseUrl)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
<!--
娴峰悍銆岃澶囩綉缁?SDK锛圚CNetSDK Win64锛夈€嶈繍琛屽簱锛岄殢绋嬪簭杈撳嚭鍒?native\HCNetSDK\銆?
杩愯鏃朵細鎸?鐜鍙橀噺 YUNCANG_HIKSDK_DIR 鈫?绋嬪簭鐩綍\native\HCNetSDK 鈫?绋嬪簭鐩綍 鐨勯『搴忔煡鎵?HCNetSDK.dll銆?
杩欓噷鐢ㄩ€氶厤绗︼紝SDK 鍗囩骇鏃跺彧瑕佹浛鎹㈢洰褰曞唴瀹瑰嵆鍙紝涓嶇敤鏀瑰伐绋嬨€?
-->
<ItemGroup>
<Content Include="native\HCNetSDK\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<!--
鈿狅笍 蹇呴』鎺掗櫎鍗曟枃浠舵墦鍖咃細榛樿浼氳濉炶繘 exe 鍐呴儴锛堣嚜瑙e帇锛夛紝
瀹夎鍖呭彧瑁?exe 鏃剁湅浼兼病闂锛屼絾 exe 浣撶Н鏆存定涓?native 鐩綍涓嶅瓨鍦紝
HCNetSDK 鐨勪緷璧栵紙HCCore.dll / HCNetSDKCom\*锛夎В鏋愪細鍙樺緱涓嶅彲鎺с€?
鏄惧紡璁╁畠浣滀负**鐙珛鏂囦欢**杈撳嚭鍒?publish\native\HCNetSDK\锛岀敱 MSI 涓€璧峰畨瑁呫€?
-->
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<!--
ffmpeg锛堥殢绋嬪簭杈撳嚭鍒?native\ffmpeg\ffmpeg.exe锛夛細鍥炴斁鏍¢獙 / 褰曞儚鍚堝苟 / 涓荤爜娴佽浆 MJPEG 閮介潬瀹冦€?
涔嬪墠娌℃墦杩涘畨瑁呭寘锛屽鎴锋満蹇呴』鑷繁瑁?ffmpeg锛岄潪鏈嶅姟绔數鑴戝氨涓嬩笉浜嗗悎骞跺悗鐨勬垚鐗囥€?
鍚屾牱瑕?ExcludeFromSingleFile 鈥斺€?200MB+ 鐨勫崟鏂囦欢闈欐€?exe 濉炶繘鑷В鍘嬪寘娌℃湁鎰忎箟銆?
杩愯鏃舵煡鎵鹃『搴忥細YUNCANG_FFMPEG 鈫?<exe鐩綍>\native\ffmpeg\ffmpeg.exe 鈫?PATH
-->
<Content Include="native\ffmpeg\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<!--
璋锋瓕娴忚鍣ㄦ彃浠讹紙浠撳簱鏍圭洰褰?extension\锛夛細闅忕▼搴忚緭鍑哄埌 native 鍚岀骇鐨?extension\锛?
瀹夎鍚庝綅浜?<瀹夎鐩綍>\extension锛岃彍鍗曘€屽伐鍏?鈫?澶嶅埗璋锋瓕鎻掍欢鍦板潃銆嶇洿鎺ョ粰鍑鸿 Windows 璺緞锛?
鐢ㄦ埛鍦?chrome://extensions 閲屻€屽姞杞藉凡瑙e帇鐨勬墿灞曠▼搴忋€嶅嵆鍙€?
寮€鍙戣皟璇曟枃浠讹紙test\ / tools\锛変笉鎵撹繘瀹夎鍖呫€?
-->
<Content Include="..\extension\**\*" Exclude="..\extension\test\**;..\extension\tools\**">
<Link>extension\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
</ItemGroup>
</Project>