forked from postsharp/PostSharp.Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedisServer.cs
More file actions
42 lines (35 loc) · 909 Bytes
/
Copy pathRedisServer.cs
File metadata and controls
42 lines (35 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace PostSharp.Samples.Caching
{
internal class RedisServer : IDisposable
{
private Process process;
private RedisServer(Process process)
{
this.process = process;
}
public void Dispose()
{
if (process != null)
{
Console.WriteLine("Stopping Redis server.");
process.Close();
process = null;
}
}
public static RedisServer Start()
{
if (!Process.GetProcessesByName("redis-server").Any())
{
var configFile = Path.GetFullPath("redis.conf");
Console.WriteLine("Starting Redis server with config file: " + configFile);
return new RedisServer(Process.Start(@"..\..\..\..\packages\redis-64.3.0.503\tools\redis-server.exe",
configFile));
}
return new RedisServer(null);
}
}
}