本文介绍如何附加探查器以及如何获取输出文件。探查器用于帮助调试游戏服务器的图形和性能相关问题。若要使用 dotnet trace 或 PIX 等工具,首先需要上传你选择的探查器。然后将其关联到生成,输出文件将放入日志文件夹中。不建议将探查器附加到生产生成,因为它可能会影响性能。
附加探查器的设置需要在创建生成时完成。目前我们不支持通过 Game Manager 附加探查器,因此你需要使用我们的 API 创建生成。有关详细信息,请参阅演练:使用 PowerShell/API 部署生成。在创建生成时,监控配置下有一个资产引用字段。将资产引用包含在监控配置中。请确保你的资产已上传到 Game Manager 中。若要了解详情,请参阅生成概述中的管理资产。对于 Linux 服务器,以下是探查器执行脚本的示例。
Script
sighdl(){ #This is the folder the monitoring output should be written to. monitoring_folder_path = "${PF_MONITORING_LOG_FOLDER}" #Code to end monitoring and copy the output exit 0}#set up the trap function to catch the signals and exit gracefullytrap sighdl SIGKILL SIGINT SIGTERMsleep 3600
对于 Windows 服务器,以下是探查器执行脚本的示例。
#Sample function that checks for the sentinel file's existence in order to end.function Check_Sentinel_File(){ $fullPath = $Env:PF_SENTINEL_FILE while(!(Test-Path $fullPath)) { Start-Sleep 10} #PF_MONITORING_LOG_FOLDER contains the log folder where the monitoring output should be saved $outputPath = "{0}/{1}" -f $Env:PF_MONITORING_LOG_FOLDER, "output.txt" "I've died!" | Out-File $outputPath}Check_Sentinel_File