gpt4 book ai didi

python - Fabric 将停止 redis 服务器,但不会再次启动它

转载 作者:太空宇宙 更新时间:2023-11-03 15:20:50 24 4
gpt4 key购买 nike

Fabric 将停止我的 Redis 服务器,但它不会启动。我尝试使用织物,但使用 paramiko 效果很好。为什么 Fabric 不启动 redis 服务器?我可以使用 paramiko,但这似乎有点反常。

[ec2-xxx-xxx-xxx.compute-1.amazonaws.com] Executing task 'redis_master_role'
[master.redis.htdevops.com] Executing task 'redis_master_stop'
[master.redis.htdevops.com] sudo: service redis_6379 stop
[master.redis.htdevops.com] out: Stopping ...
[master.redis.htdevops.com] out: Waiting for Redis to shutdown ...
[master.redis.htdevops.com] out: Redis stopped
[master.redis.htdevops.com] out:


#Fail 1
[master.redis.htdevops.com] sudo: service redis_6379 start
[master.redis.htdevops.com] out: Starting Redis server...
[master.redis.htdevops.com] out:

#Fail 2
[master.redis.htdevops.com] sudo: service redis_6379 start
[master.redis.htdevops.com] out: Starting Redis server...
[master.redis.htdevops.com] out:

#Started by paramiko
Starting Redis server...



def redis_master_role():
env.roles = ['redis']
def redis_master_stop():
sudo('service redis_6379 stop')
time.sleep(5)
def redis_master_start():
sudo('service redis_6379 start')
time.sleep(5)
sudo('service redis_6379 start')

keypair_path = "/home/ubuntu/.ec2/test.pem"
key = paramiko.RSAKey.from_private_key_file(keypair_path)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(redis_master,22,username='ubuntu',pkey=key,timeout=60)
cmd = 'sudo service redis_6379 start'
stdin, stdout, stderr = ssh.exec_command(cmd)
print stdout.read()
ssh.close()



def redis_bootstrap():
env.user = "ubuntu"
env.key_filename = "/home/ubuntu/.ec2/test.pem"

execute('redis_master_role')
execute('redis_master_stop')
execute('redis_master_put')
execute('redis_master_start')

最佳答案

检查这个:fabric appears to start apache2 but doesn't

但基本上,试试这个:

sudo('service redis_6379 start', pty=False)

关于python - Fabric 将停止 redis 服务器,但不会再次启动它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15273321/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com