mirror of
https://github.com/healthchecks/healthchecks.git
synced 2024-11-23 16:07:39 +00:00
14 lines
2.2 KiB
HTML
14 lines
2.2 KiB
HTML
<div class="highlight"><pre><span></span><span class="k">try</span><span class="w"></span>
|
|
<span class="p">{</span><span class="w"></span>
|
|
<span class="w"> </span><span class="k">using</span><span class="w"> </span><span class="p">(</span><span class="kt">var</span><span class="w"> </span><span class="n">client</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">System</span><span class="p">.</span><span class="n">Net</span><span class="p">.</span><span class="n">Http</span><span class="p">.</span><span class="n">HttpClient</span><span class="p">())</span><span class="w"></span>
|
|
<span class="w"> </span><span class="p">{</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">client</span><span class="p">.</span><span class="n">Timeout</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">System</span><span class="p">.</span><span class="n">TimeSpan</span><span class="p">.</span><span class="n">FromSeconds</span><span class="p">(</span><span class="m">10</span><span class="p">);</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">client</span><span class="p">.</span><span class="n">GetAsync</span><span class="p">(</span><span class="s">"{{ ping_url }}"</span><span class="p">).</span><span class="n">Wait</span><span class="p">();</span><span class="w"></span>
|
|
<span class="w"> </span><span class="p">}</span><span class="w"></span>
|
|
<span class="p">}</span><span class="w"></span>
|
|
<span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="n">System</span><span class="p">.</span><span class="n">Exception</span><span class="w"> </span><span class="n">ex</span><span class="p">)</span><span class="w"></span>
|
|
<span class="p">{</span><span class="w"></span>
|
|
<span class="w"> </span><span class="n">System</span><span class="p">.</span><span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"Ping failed: {ex.Message}"</span><span class="p">);</span><span class="w"></span>
|
|
<span class="p">}</span><span class="w"></span>
|
|
</pre></div>
|