def main():
options.parse_command_line()
if os.path.exists(options.configFile):
try:
options.parse_config_file(options.configFile)
options.parse_command_line()
except Exception, E:
print("Invalid config file {0}".format(options.configFile))
print(E)
sys.exit(1)
# Set Log level
log.setLevel(getLogLevel(options.logLevel))
detectProxy()
# Load the credentials from file
log.info("Loading credentials")
try:
credentialsFile = options.credentialsFile
Keys.loadFromFile(credentialsFile)
except Exception as E:
log.error("Error opening the credentials file: {0}".format(credentialsFile))
log.error(E)
sys.exit(1)
# TMP fix for 'ValueError: I/O operation on closed epoll fd'
# Fixed in Tornado 4.2
tornado.ioloop.IOLoop.instance()
# Sync time to CertiVox time server
if options.syncTime:
Time.getTime(wait=True)
if options.backup and options.encrypt_master_secret and not options.passphrase:
options.passphrase = getpass.getpass("Please enter passphrase:")
http_server = Application()
http_server.listen(options.port, options.address, xheaders=True)
io_loop = tornado.ioloop.IOLoop.instance()
if options.autoReload:
log.debug("Starting autoreloader")
tornado.autoreload.watch(CONFIG_FILE)
tornado.autoreload.start(io_loop)
if options.syncTime and (options.timePeriod > 0):
scheduler = tornado.ioloop.PeriodicCallback(Time.getTime, options.timePeriod, io_loop=io_loop)
scheduler.start()
log.info("Server started. Listening on {0}:{1}".format(options.address, options.port))
io_loop.start()
评论列表
文章目录