【发布时间】:2016-01-29 06:04:15
【问题描述】:
我对结构很陌生,我正在尝试创建一个脚本来启动三个不同的服务器和一个客户端,但它似乎在第一个任务时停止。这是我的代码:
env.user='userX'
env.roledefs = {
'client':['HostC'],
'id 0':['Host0'],
'id 1':['Host1'],
'id 2':['Host2']
}
def go():
execute(serve0)
execute(serve1)
execute(serve2)
execute(req)
@roles('id 0')
def serve0():
run('./go/bin/kvsd -id 0 -config-file ~/go/src/github.com/userX/kvs/kvsd/conf/config.ini')
@roles('id 1')
def serve1():
run('./go/bin/kvsd -id 1 -config-file ~/go/src/github.com/userX/kvs/kvsd/conf/config.ini')
@roles('id 2')
def serve2():
run('./go/bin/kvsd -id 2 -config-file ~/go/src/github.com/userX/kvs/kvsd/conf/config.ini')
@roles('client')
def req():
run('./go/bin/kvsc -config-file ~/go/src/github.com/userX/kvs/kvsc/config.ini')
我用“fab go”运行它,但这只会导致它执行serve0,它不会在没有中断的情况下停止,因此会阻止任何其他任务的执行。有没有办法让它们并行运行?另外,有没有更好的方法将特定任务与特定主机联系起来?
【问题讨论】:
标签: python python-2.7 fabric