- change : 增加自动链接CTP和链接MongoDB
This commit is contained in:
parent
e512ea59db
commit
287836bf28
@ -70,6 +70,8 @@ def printLog(content):
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def runServer():
|
def runServer():
|
||||||
"""运行服务器"""
|
"""运行服务器"""
|
||||||
|
VT_setting = vtGlobal.VT_setting
|
||||||
|
|
||||||
repAddress = 'tcp://*:2014'
|
repAddress = 'tcp://*:2014'
|
||||||
pubAddress = 'tcp://*:0602'
|
pubAddress = 'tcp://*:0602'
|
||||||
|
|
||||||
@ -80,18 +82,35 @@ def runServer():
|
|||||||
printLog('-'*50)
|
printLog('-'*50)
|
||||||
printLog(u'vn.trader服务器已启动')
|
printLog(u'vn.trader服务器已启动')
|
||||||
|
|
||||||
# 进入主循环
|
if VT_setting.get('automongodb'):
|
||||||
while True:
|
# 自动建立MongoDB数据库
|
||||||
printLog(u'请输入exit来关闭服务器')
|
printLog(u'MongoDB connect... ')
|
||||||
if raw_input() != 'exit':
|
server.engine.dbConnect()
|
||||||
continue
|
|
||||||
|
|
||||||
printLog(u'确认关闭服务器?yes|no')
|
if VT_setting.get('autoctp'):
|
||||||
if raw_input() == 'yes':
|
# 自动建立CTP链接
|
||||||
break
|
printLog(u"CTP connect... ")
|
||||||
|
server.engine.connect("CTP")
|
||||||
|
|
||||||
|
if VT_setting.get('autoshutdown'):
|
||||||
|
# 自动关闭 线程阻塞
|
||||||
|
wait2shutdown = autoshutdown()
|
||||||
|
printLog(u"time to shutdown %s" % wait2shutdown.closeTime)
|
||||||
|
wait2shutdown.join()
|
||||||
|
else:
|
||||||
|
# 进入主循环
|
||||||
|
while True:
|
||||||
|
printLog(u'input "exit" to exit')
|
||||||
|
if raw_input() != 'exit':
|
||||||
|
continue
|
||||||
|
|
||||||
|
printLog(u'confirm?yes|no')
|
||||||
|
if raw_input() == 'yes':
|
||||||
|
break
|
||||||
|
|
||||||
server.stopServer()
|
server.stopServer()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
opt = ArgumentParser(
|
opt = ArgumentParser(
|
||||||
prog="vnpy",
|
prog="vnpy",
|
||||||
|
Loading…
Reference in New Issue
Block a user