无法使用 Tornado 服务器配置 Openshift 3

Cannot configure Openshift 3 with Tornado server

我正在尝试将我的 Tornado 应用程序从 Openshift2 迁移到 Openshift3,但不知道如何实际设置路线、服务等。

首先,我在 RHEL 7 上创建简单的 Python 3.5 应用程序。在高级选项中,我设置了 git 存储库,添加 APP_FILE 变量。克隆和应用程序构建成功完成。我在 web 控制台终端中执行了 curl localhost:8080,它似乎工作正常。

但是服务根 link returns 我这条消息:

Application is not available

The application is currently not serving requests at this endpoint. It may not have been started or is still starting.

实际上我没有更改路由和服务配置中的任何内容,我想我应该以某种方式设置它。但是现在还没想好怎么办。

这是我的 wsgi.py:

#!/usr/bin/env python
import importlib.machinery

if __name__ == '__main__':
    print('Executing __main__ ...')
    ip = 'localhost'
    port = 8080
    app = importlib.machinery.SourceFileLoader("application", 'wsgi/application').load_module("application")

    from wsgiref.simple_server import make_server
    httpd = make_server(ip, port, app.application)
    print('Starting server on http://{0}:{1}'.format(ip, port))
    httpd.serve_forever()

application

#!/usr/bin/env python
import os
import sys

import tornado.wsgi
from wsgi.openshift import handlers

if 'OPENSHIFT_REPO_DIR' in os.environ:
    sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi',))
    virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/venv'
    os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python3.3/site-packages')
    virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
    try:
        exec(compile(open(virtualenv).read(), virtualenv, 'exec'), dict(__file__=virtualenv))
    except IOError:
        pass

 settings = {
     'cookie_secret': 'TOP_SECRET',
     'static_path' : os.path.join(os.getcwd(), 'wsgi/static'),
     'template_path' : os.path.join(os.getcwd(), 'wsgi/templates'),
     'xsrf_cookies': False,
     'debug': True,
     'login_url': '/login',
 }

application = tornado.wsgi.WSGIApplication(handlers, **settings)

编辑:

这是一些控制台 oc 输出:

> oc status
In project photoservice on server https://api.starter-us-west-1.openshift.com:443

http://photoservice-photoservice.a3c1.starter-us-west-1.openshiftapps.com to pod port 8080-tcp (svc/photoservice)
  dc/photoservice deploys istag/photoservice:latest <-
    bc/photoservice source builds git@bitbucket.org:ashchuk/photoservice.git#master on openshift/python:3.5
    deployment #1 deployed 3 minutes ago - 1 pod

View details with 'oc describe <resource>/<name>' or list everything with 'oc get all'.

> oc get routes
NAME           HOST/PORT                                                            PATH      SERVICES       PORT       TERMINATION   WILDCARD
photoservice   photoservice-photoservice.a3c1.starter-us-west-1.openshiftapps.com             photoservice   8080-tcp                 None

刚刚将 ip = 'localhost' 更改为 ip = '0.0.0.0' 作为 并且这有效。

这是一个 :

If you use localhost or 127.0.0.1 it will only accept requests from the network loopback device. This can only be connected to by clients running on the same host (container). You need to listen on all network interfaces, indicated by 0.0.0.0 to be able to accept requests from outside of the host (container). If you don't do that, OpenShift cannot connect to your application to proxy requests to it.