David Fowler
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
5 additions and
2 deletions
-
src/Microsoft.Tye.Core/DockerDetector.cs
|
|
@ -3,12 +3,15 @@ |
|
|
// See the LICENSE file in the project root for more information.
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
|
|
using System; |
|
|
using System; |
|
|
|
|
|
using System.Threading; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
namespace Microsoft.Tye |
|
|
namespace Microsoft.Tye |
|
|
{ |
|
|
{ |
|
|
public class DockerDetector |
|
|
public class DockerDetector |
|
|
{ |
|
|
{ |
|
|
|
|
|
private static readonly TimeSpan Timeout = TimeSpan.FromSeconds(10); |
|
|
|
|
|
|
|
|
public static DockerDetector Instance { get; } = new DockerDetector(); |
|
|
public static DockerDetector Instance { get; } = new DockerDetector(); |
|
|
|
|
|
|
|
|
private DockerDetector() |
|
|
private DockerDetector() |
|
|
@ -25,7 +28,7 @@ namespace Microsoft.Tye |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
await ProcessUtil.RunAsync("docker", "version", throwOnError: false); |
|
|
await ProcessUtil.RunAsync("docker", "version", throwOnError: false, cancellationToken: new CancellationTokenSource(Timeout).Token); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
catch (Exception) |
|
|
catch (Exception) |
|
|
@ -39,7 +42,7 @@ namespace Microsoft.Tye |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
var result = await ProcessUtil.RunAsync("docker", "version", throwOnError: false); |
|
|
var result = await ProcessUtil.RunAsync("docker", "version", throwOnError: false, cancellationToken: new CancellationTokenSource(Timeout).Token); |
|
|
return result.ExitCode == 0; |
|
|
return result.ExitCode == 0; |
|
|
} |
|
|
} |
|
|
catch (Exception) |
|
|
catch (Exception) |
|
|
|