python waitress serve_Python server.create_app方法代码示例

# 需要导入模块: import server [as 别名]

# 或者: from server import create_app [as 别名]

def main():

args = _get_args()

level = args['log_level'].upper()

level = log_levels.get(level, logging.INFO)

log = setup_logging(log_level=level)

import core, utils, server

config_file = args['CONFIG']

if not utils.file_exists(config_file):

log.error('File %s does not exist' % (config_file))

sys.exit(1)

log.info('Validating config')

try:

core.Engine.validate_config(config_file)

except core.ConfigValidationError as ex:

log.error('Invalid config. %s' % (str(ex)))

sys.exit(1)

log.info('Initializing xFlow engine')

engine = core.Engine(config_file)

log.info('Config is valid')

# Run as server

if args['s']:

logging.info('Configuring xFlow Engine')

engine.configure()

app = server.create_app(engine)

logging.info('Running as server')

app.run(host='0.0.0.0', port=80, server='waitress', loglevel='warning')

# Configure the lambdas, streams and subscriptions

if args['c']:

logging.info('Configuring xFlow Engine')

engine.configure()

logging.info('xFlow Engine configured')

# Publish json data to stream

if args['p']:

stream = args['p'][0]

data = args['p'][1]

log.info('\n\n\nPublishing to stream: %s\n\nData: %s' % (stream, data))

try:

engine.publish(stream, data)

log.info('Published')

except core.KinesisStreamDoesNotExist:

sys.exit(1)

# Track a workflow

if args['t']:

workflow_id = args['t'][0]

execution_id = args['t'][1]

log.info("\n\n\nTracking workflow, workflow_id=%s, execution_id=%s" % (workflow_id, execution_id))

try:

tracking_info = engine.track(workflow_id, execution_id)

print json.dumps(tracking_info, indent=4)

except (core.CloudWatchStreamDoesNotExist,

core.WorkflowDoesNotExist,

core.CloudWatchLogDoesNotExist):

sys.exit(1)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值