1 Star 0 Fork 18

QLTH / Redis for Windows

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Program.cs 1.22 KB
一键复制 编辑 原始数据 按行查看 历史
me2fish 提交于 2023-02-25 01:32 . Create Program.cs
//author: https://www.zhihu.com/question/424272611/answer/2611312760
using System.Diagnostics;
using System.ServiceProcess;
namespace RedisService
{
class Program
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:验证平台兼容性", Justification = "<挂起>")]
static void Main()
{
ServiceBase.Run(new RedisService());
}
}
partial class RedisService : ServiceBase
{
private Process? process = new();
protected override void OnStart(string[] args)
{
var basePath = Path.Combine(AppContext.BaseDirectory).Replace("\\", "/");
var diskSymbol = basePath[..basePath.IndexOf(":")];
var confPath = basePath.Replace(diskSymbol + ":", "/cygdrive/" + diskSymbol);
ProcessStartInfo processStartInfo = new(basePath + "redis-server.exe", confPath + "redis.conf");
processStartInfo.WorkingDirectory = basePath;
process = Process.Start(processStartInfo);
}
protected override void OnStop()
{
if (process != null)
{
process.Kill();
process.Dispose();
}
}
}
}
1
https://gitee.com/qlth/redis-windows.git
git@gitee.com:qlth/redis-windows.git
qlth
redis-windows
Redis for Windows
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891