mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-24 21:46:52 +01:00
166 lines
20 KiB
HTML
166 lines
20 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
|
<meta name="generator" content="Doxygen 1.9.8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>tgstation-server: src/Tgstation.Server.Host/System/DotnetDumpService.cs Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr id="projectrow">
|
|
<td id="projectalign">
|
|
<div id="projectname">tgstation-server<span id="projectnumber"> 6.19.3</span>
|
|
</div>
|
|
<div id="projectbrief">The /tg/station 13 server suite</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.9.8 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
|
$(document).ready(function() { init_codefold(0); });
|
|
/* @license-end */
|
|
</script>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<div id="MSearchResults">
|
|
<div class="SRPage">
|
|
<div id="SRIndex">
|
|
<div id="SRResults"></div>
|
|
<div class="SRStatus" id="Loading">Loading...</div>
|
|
<div class="SRStatus" id="Searching">Searching...</div>
|
|
<div class="SRStatus" id="NoMatches">No Matches</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_34761767c1c3cd212f9d2f80ea0828a8.html">Tgstation.Server.Host</a></li><li class="navelem"><a class="el" href="dir_3d220027e29e19c608b6d51ce3029c32.html">System</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle"><div class="title">DotnetDumpService.cs</div></div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<a href="_dotnet_dump_service_8cs.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="keyword">using </span>System;</div>
|
|
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span><span class="keyword">using </span>System.Threading;</div>
|
|
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="keyword">using </span>System.Threading.Tasks;</div>
|
|
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span> </div>
|
|
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="keyword">using </span>Microsoft.Diagnostics.NETCore.Client;</div>
|
|
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span><span class="keyword">using </span>Microsoft.Extensions.Logging;</div>
|
|
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span> </div>
|
|
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="keyword">using </span><a class="code hl_namespace" href="namespace_tgstation_1_1_server_1_1_api_1_1_models.html">Tgstation.Server.Api.Models</a>;</div>
|
|
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span><span class="keyword">using </span><a class="code hl_namespace" href="namespace_tgstation_1_1_server_1_1_host_1_1_jobs.html">Tgstation.Server.Host.Jobs</a>;</div>
|
|
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span> </div>
|
|
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespace_tgstation_1_1_server_1_1_host_1_1_system.html">Tgstation.Server.Host.System</a></div>
|
|
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span>{</div>
|
|
<div class="foldopen" id="foldopen00014" data-start="{" data-end="};">
|
|
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"><a class="line" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html"> 14</a></span> <span class="keyword">sealed</span> <span class="keyword">class </span><a class="code hl_class" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html">DotnetDumpService</a> : <a class="code hl_interface" href="interface_tgstation_1_1_server_1_1_host_1_1_system_1_1_i_dotnet_dump_service.html">IDotnetDumpService</a></div>
|
|
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> {</div>
|
|
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"><a class="line" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#aabfb0f0373dbb5a4c364d400bc8c9f72"> 19</a></span> readonly ILogger<DotnetDumpService> <a class="code hl_variable" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#aabfb0f0373dbb5a4c364d400bc8c9f72">logger</a>;</div>
|
|
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> </div>
|
|
<div class="foldopen" id="foldopen00025" data-start="{" data-end="}">
|
|
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"><a class="line" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#a6619936a003fbd860a4db0ea5a35c71f"> 25</a></span> <span class="keyword">public</span> <a class="code hl_function" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#a6619936a003fbd860a4db0ea5a35c71f">DotnetDumpService</a>(</div>
|
|
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> ILogger<DotnetDumpService> <a class="code hl_variable" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#aabfb0f0373dbb5a4c364d400bc8c9f72">logger</a>)</div>
|
|
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> {</div>
|
|
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span> this.logger = <a class="code hl_variable" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#aabfb0f0373dbb5a4c364d400bc8c9f72">logger</a> ?? <span class="keywordflow">throw</span> <span class="keyword">new</span> ArgumentNullException(nameof(<a class="code hl_variable" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#aabfb0f0373dbb5a4c364d400bc8c9f72">logger</a>));</div>
|
|
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> }</div>
|
|
</div>
|
|
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> </div>
|
|
<div class="foldopen" id="foldopen00032" data-start="{" data-end="}">
|
|
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"><a class="line" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#a4baaea7bb7fd77e2e8e04d104cfc20a1"> 32</a></span> <span class="keyword">public</span> async ValueTask <a class="code hl_function" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#a4baaea7bb7fd77e2e8e04d104cfc20a1">Dump</a>(<a class="code hl_interface" href="interface_tgstation_1_1_server_1_1_host_1_1_system_1_1_i_process.html">IProcess</a> process, <span class="keywordtype">string</span> outputFile, <span class="keywordtype">bool</span> minidump, CancellationToken cancellationToken)</div>
|
|
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> {</div>
|
|
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> <span class="comment">// need to use an extra timeout here because if the process is truly deadlocked. A cooperative dump will hang forever</span></div>
|
|
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> <span class="keyword">using </span>var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);</div>
|
|
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> </div>
|
|
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> <span class="keyword">const</span> <span class="keywordtype">int</span> TimeoutMinutes = 5;</div>
|
|
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> cts.CancelAfter(TimeSpan.FromMinutes(TimeoutMinutes));</div>
|
|
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> cts.Token.Register(() =></div>
|
|
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> {</div>
|
|
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> <span class="keywordflow">if</span> (!cancellationToken.IsCancellationRequested)</div>
|
|
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <a class="code hl_variable" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#aabfb0f0373dbb5a4c364d400bc8c9f72">logger</a>.LogError(<span class="stringliteral">"dotnet-dump timed out after {minutes} minutes!"</span>, TimeoutMinutes);</div>
|
|
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> });</div>
|
|
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> </div>
|
|
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> var pid = process.<a class="code hl_property" href="interface_tgstation_1_1_server_1_1_host_1_1_system_1_1_i_process.html#a7246c39b82b59ca759497f0fbd8bc2da">Id</a>;</div>
|
|
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> <a class="code hl_variable" href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#aabfb0f0373dbb5a4c364d400bc8c9f72">logger</a>.LogDebug(<span class="stringliteral">"dotnet-dump requested for PID {pid}..."</span>, pid);</div>
|
|
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> var client = <span class="keyword">new</span> DiagnosticsClient(pid);</div>
|
|
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> <span class="keywordflow">try</span></div>
|
|
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> {</div>
|
|
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> await client.WriteDumpAsync(</div>
|
|
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> minidump</div>
|
|
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> ? DumpType.Normal</div>
|
|
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> : DumpType.Full,</div>
|
|
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> outputFile,</div>
|
|
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <span class="keyword">false</span>,</div>
|
|
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> cts.Token);</div>
|
|
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> }</div>
|
|
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> <span class="keywordflow">catch</span> (<a class="code hl_class" href="class_exception.html">Exception</a> ex)</div>
|
|
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> {</div>
|
|
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code hl_class" href="class_tgstation_1_1_server_1_1_host_1_1_jobs_1_1_job_exception.html">JobException</a>(<a class="code hl_enumeration" href="namespace_tgstation_1_1_server_1_1_api_1_1_models.html#a1a6adb59dd51244efabf4e548e7075c8">ErrorCode</a>.GCoreFailure, ex);</div>
|
|
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> }</div>
|
|
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> }</div>
|
|
</div>
|
|
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> }</div>
|
|
</div>
|
|
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span>}</div>
|
|
<div class="ttc" id="aclass_exception_html"><div class="ttname"><a href="class_exception.html">Exception</a></div></div>
|
|
<div class="ttc" id="aclass_tgstation_1_1_server_1_1_host_1_1_jobs_1_1_job_exception_html"><div class="ttname"><a href="class_tgstation_1_1_server_1_1_host_1_1_jobs_1_1_job_exception.html">Tgstation.Server.Host.Jobs.JobException</a></div><div class="ttdoc">Operation exceptions thrown from the context of a Models.Job.</div><div class="ttdef"><b>Definition</b> <a href="_job_exception_8cs_source.html#l00010">JobException.cs:11</a></div></div>
|
|
<div class="ttc" id="aclass_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service_html"><div class="ttname"><a href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html">Tgstation.Server.Host.System.DotnetDumpService</a></div><div class="ttdef"><b>Definition</b> <a href="_dotnet_dump_service_8cs_source.html#l00014">DotnetDumpService.cs:15</a></div></div>
|
|
<div class="ttc" id="aclass_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service_html_a4baaea7bb7fd77e2e8e04d104cfc20a1"><div class="ttname"><a href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#a4baaea7bb7fd77e2e8e04d104cfc20a1">Tgstation.Server.Host.System.DotnetDumpService.Dump</a></div><div class="ttdeci">async ValueTask Dump(IProcess process, string outputFile, bool minidump, CancellationToken cancellationToken)</div><div class="ttdoc">Attempt to dump a given process .A ValueTask representing the running operation.</div><div class="ttdef"><b>Definition</b> <a href="_dotnet_dump_service_8cs_source.html#l00032">DotnetDumpService.cs:32</a></div></div>
|
|
<div class="ttc" id="aclass_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service_html_a6619936a003fbd860a4db0ea5a35c71f"><div class="ttname"><a href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#a6619936a003fbd860a4db0ea5a35c71f">Tgstation.Server.Host.System.DotnetDumpService.DotnetDumpService</a></div><div class="ttdeci">DotnetDumpService(ILogger< DotnetDumpService > logger)</div><div class="ttdoc">Initializes a new instance of the DotnetDumpService class.</div><div class="ttdef"><b>Definition</b> <a href="_dotnet_dump_service_8cs_source.html#l00025">DotnetDumpService.cs:25</a></div></div>
|
|
<div class="ttc" id="aclass_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service_html_aabfb0f0373dbb5a4c364d400bc8c9f72"><div class="ttname"><a href="class_tgstation_1_1_server_1_1_host_1_1_system_1_1_dotnet_dump_service.html#aabfb0f0373dbb5a4c364d400bc8c9f72">Tgstation.Server.Host.System.DotnetDumpService.logger</a></div><div class="ttdeci">readonly ILogger< DotnetDumpService > logger</div><div class="ttdoc">The ILogger for the DotnetDumpService.</div><div class="ttdef"><b>Definition</b> <a href="_dotnet_dump_service_8cs_source.html#l00019">DotnetDumpService.cs:19</a></div></div>
|
|
<div class="ttc" id="ainterface_tgstation_1_1_server_1_1_host_1_1_system_1_1_i_dotnet_dump_service_html"><div class="ttname"><a href="interface_tgstation_1_1_server_1_1_host_1_1_system_1_1_i_dotnet_dump_service.html">Tgstation.Server.Host.System.IDotnetDumpService</a></div><div class="ttdoc">Service for managing the dotnet-dump installation.</div><div class="ttdef"><b>Definition</b> <a href="_i_dotnet_dump_service_8cs_source.html#l00009">IDotnetDumpService.cs:10</a></div></div>
|
|
<div class="ttc" id="ainterface_tgstation_1_1_server_1_1_host_1_1_system_1_1_i_process_html"><div class="ttname"><a href="interface_tgstation_1_1_server_1_1_host_1_1_system_1_1_i_process.html">Tgstation.Server.Host.System.IProcess</a></div><div class="ttdoc">Abstraction over a global::System.Diagnostics.Process.</div><div class="ttdef"><b>Definition</b> <a href="_i_process_8cs_source.html#l00010">IProcess.cs:11</a></div></div>
|
|
<div class="ttc" id="ainterface_tgstation_1_1_server_1_1_host_1_1_system_1_1_i_process_html_a7246c39b82b59ca759497f0fbd8bc2da"><div class="ttname"><a href="interface_tgstation_1_1_server_1_1_host_1_1_system_1_1_i_process.html#a7246c39b82b59ca759497f0fbd8bc2da">Tgstation.Server.Host.System.IProcess.Id</a></div><div class="ttdeci">int Id</div><div class="ttdoc">The IProcess' ID.</div><div class="ttdef"><b>Definition</b> <a href="_i_process_8cs_source.html#l00015">IProcess.cs:15</a></div></div>
|
|
<div class="ttc" id="anamespace_tgstation_1_1_server_1_1_api_1_1_models_html"><div class="ttname"><a href="namespace_tgstation_1_1_server_1_1_api_1_1_models.html">Tgstation.Server.Api.Models</a></div><div class="ttdef"><b>Definition</b> <a href="_tgstation_8_server_8_api_2_models_2_chat_channel_8cs_source.html#l00005">ChatChannel.cs:6</a></div></div>
|
|
<div class="ttc" id="anamespace_tgstation_1_1_server_1_1_api_1_1_models_html_a1a6adb59dd51244efabf4e548e7075c8"><div class="ttname"><a href="namespace_tgstation_1_1_server_1_1_api_1_1_models.html#a1a6adb59dd51244efabf4e548e7075c8">Tgstation.Server.Api.Models.ErrorCode</a></div><div class="ttdeci">ErrorCode</div><div class="ttdoc">Types of Response.ErrorMessageResponses that the API may return.</div><div class="ttdef"><b>Definition</b> <a href="_error_code_8cs_source.html#l00011">ErrorCode.cs:12</a></div></div>
|
|
<div class="ttc" id="anamespace_tgstation_1_1_server_1_1_host_1_1_jobs_html"><div class="ttname"><a href="namespace_tgstation_1_1_server_1_1_host_1_1_jobs.html">Tgstation.Server.Host.Jobs</a></div><div class="ttdef"><b>Definition</b> <a href="_i_job_manager_8cs_source.html#l00007">IJobManager.cs:8</a></div></div>
|
|
<div class="ttc" id="anamespace_tgstation_1_1_server_1_1_host_1_1_system_html"><div class="ttname"><a href="namespace_tgstation_1_1_server_1_1_host_1_1_system.html">Tgstation.Server.Host.System</a></div><div class="ttdef"><b>Definition</b> <a href="_assembly_information_provider_8cs_source.html#l00008">AssemblyInformationProvider.cs:9</a></div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
|
|
</small></address>
|
|
</body>
|
|
</html>
|