windows 下python 脚本启动多个redis服务
2023-06-13 09:12:24 时间
刚开始用bat脚本写的批量启动,但是一直卡到第一个redis启动,查询尝试无果,果断用python写了一个简单的脚本。
- 附上redis安装目录结构
- 附上程序代码
# python >=2.x
import os
import threading
def makefile(_path, _name, _content):
# type: (str, str, str) -> str
filer = _path + _name
if not os.path.exists(_path):
print('the path is not exists')
else:
if not os.path.isdir(_path):
print('the dir name is not exists')
else:
if not os.path.isfile(filer):
f = open(filer, 'w+')
f.write(_content)
f.seek(0)
else:
print(filer + ' exists')
def execute_cmd_command(command_str, f, tags):
command_str = command_str + ' D:\phpstudy_pro\Extensions\\redis3.0.504\config\\' + f + '>>D:\dev\python\logs\\' + tags + '_log.txt 2>&1'
os.system(command_str)
def file_name(file_dir, _names):
# type: (str) -> str
system = str('D:\phpstudy_pro\Extensions\\redis3.0.504\\redis-server.exe') # type: str
if not os.path.isfile(system):
pass
else:
for root, dirs, files in os.walk(file_dir):
for f in files:
if str(os.path.splitext(f)[0]) + str(os.path.splitext(f)[1]) in _names:
if os.path.splitext(f)[1] == '.conf':
t = threading.Thread(target=execute_cmd_command, args=(system, f, os.path.splitext(f)[0]))
t.start()
default = '6379,6380,6381' # type: str
source = input('Enter your input eg(6379,6380,6381): ')
source = default if len(source) == 0 else source
ports = source.split(',')
names = []
for port in ports:
path = str('D:\phpstudy_pro\Extensions\\redis3.0.504\config\\')
name = str('redis-' + port + '.conf')
names.append(name)
content = str('bind 127.0.0.1\nport ' + port + '\ntimeout 65\nmaxclients 10000\ndatabases 16\nmaxmemory 1048576000')
makefile(path, name, content)
conf = 'D:\phpstudy_pro\Extensions\\redis3.0.504\config\\'
file_name(conf, names)
相关文章
- Redis的Python客户端redis-py安装使用说明文档
- Python操作Redis实现数据持久化(python操作redis)
- Python实现快速连接Redis数据库(python连接redis)
- ymysql在Python中使用Redis CLI和Pymysql(redis cli p)
- 理解Redis 深入浅出(怎么理解redis数据库)
- 如何应对Redis高并发访问问题(怎么处理redis高并发)
- 远程读写利用事务同步器实现Redis远程读写(事务同步器处理redis)
- Windows环境下搭建Redis服务器(win运行redis)
- 从零开始,Windows下玩转Redis(win怎么使用redis)
- Windows下修改Redis服务器密码方法(win修改redis密码)
- Windows系统下利用Redis缓存技术(win下的redis)
- Windows下快速安装Redis服务(win下redis下载)
- 基于Windows环境下Redis服务器配置实践(win redis配置)
- 获胜Windows 下管理 Redis 的命令使用指南(win redis命令)
- 便携式在Windows上运行Redis(window版redis)
- Windows 7系统能使用Redis吗(win7能用redis吗)
- 比较分析Tair与Redis的异同(tair redis对比)
- 拓展多维度大数据Redis助力(多维度大数据 redis)
- 究竟Redis占用多大内存(redis需要占多大内存)
- 的红色神器Redis集群部署指南(redis集群是如何部署)
- 简捷掌握Redis集合常用命令(redis集合常用命令)
- 对孤掌难鸣Windows环境下Redis安装指南(widow安装redis)
- 面试前准备精通Redis连接池的技术知识(redis连接池面试)
- 死去的记忆Redis过期数据的困境(redis 过期的数据)
- Redis与缓存异曲同工的优势与区别(redis跟缓存区别)