- change : 命令行启动 vtServer.py 可以通过参数指定 VT_setting.json
This commit is contained in:
parent
2d45b7a586
commit
f8d48bd4b9
@ -1,14 +1,12 @@
|
||||
# encoding: utf-8
|
||||
|
||||
import sys
|
||||
import vtGlobal
|
||||
import json
|
||||
import os
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
|
||||
import vtPath
|
||||
import eventType
|
||||
from vnrpc import RpcServer
|
||||
from vtEngine import MainEngine
|
||||
|
||||
@ -95,4 +93,25 @@ def runServer():
|
||||
server.stopServer()
|
||||
|
||||
if __name__ == '__main__':
|
||||
opt = ArgumentParser(
|
||||
prog="vnpy",
|
||||
description="Args of vnpy.",
|
||||
)
|
||||
|
||||
# VT_setting.json 文件路径
|
||||
opt.add_argument("--VT_setting", default=None, help="重新指定VT_setting.json的绝对路径")
|
||||
|
||||
# 生成参数实例
|
||||
cmdArgs = opt.parse_args()
|
||||
|
||||
if cmdArgs.VT_setting is None:
|
||||
fileName = 'VT_setting.json'
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
fileName = os.path.join(path, fileName)
|
||||
else:
|
||||
fileName = cmdArgs.VT_setting
|
||||
|
||||
with open(fileName) as f:
|
||||
vtGlobal.VT_setting = json.load(f)
|
||||
|
||||
runServer()
|
Loading…
Reference in New Issue
Block a user