1 Star 0 Fork 25

Superman~/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();
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/IwillFind/redis-windows.git
git@gitee.com:IwillFind/redis-windows.git
IwillFind
redis-windows
Redis for Windows
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385