From 287836bf284f7bb0dfcd15d6bffe2efcb65810d9 Mon Sep 17 00:00:00 2001 From: lamter Date: Wed, 26 Apr 2017 22:38:53 +0800 Subject: [PATCH] =?UTF-8?q?=20-=20change=20:=20=E5=A2=9E=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=93=BE=E6=8E=A5CTP=E5=92=8C=E9=93=BE=E6=8E=A5MongoD?= =?UTF-8?q?B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/vtServer.py | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/vn.trader/vtServer.py b/vn.trader/vtServer.py index f6d3b1be..f2d877cd 100644 --- a/vn.trader/vtServer.py +++ b/vn.trader/vtServer.py @@ -70,6 +70,8 @@ def printLog(content): #---------------------------------------------------------------------- def runServer(): """运行服务器""" + VT_setting = vtGlobal.VT_setting + repAddress = 'tcp://*:2014' pubAddress = 'tcp://*:0602' @@ -80,18 +82,35 @@ def runServer(): printLog('-'*50) printLog(u'vn.trader服务器已启动') - # 进入主循环 - while True: - printLog(u'请输入exit来关闭服务器') - if raw_input() != 'exit': - continue + if VT_setting.get('automongodb'): + # 自动建立MongoDB数据库 + printLog(u'MongoDB connect... ') + server.engine.dbConnect() - printLog(u'确认关闭服务器?yes|no') - if raw_input() == 'yes': - break + if VT_setting.get('autoctp'): + # 自动建立CTP链接 + 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() + if __name__ == '__main__': opt = ArgumentParser( prog="vnpy",