3

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')
4

1 回答 1

4

检查这个:fabric 似乎启动 apache2 但没有

但基本上,试试这个:

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

于 2013-03-29T19:48:05.557 回答