我如何从 OpenShift 跟踪日志以详细说明 python setup.py、virtualenv 和 pip?

How can I tail logs from OpenShift to be verbose about python setup.py, virtualenv, and pip?

当我运行:

rhc tail -a myapp

我确实在应用程序启动时看到了日志消息流,但没有关于 virtualenv 的设置和 requirements.txt 中依赖项的安装,例如 flask 等。我如何才能更好地在服务器上监控它调试之用,万一我运行成问题?这在 Heroku 中相当容易做到,但我正在考虑将应用程序迁移到 OpenShift,但前提是调试选项 python 非常灵活。

在我看来,在这种情况下最好的做法是通过 ssh 连接到您的设备。登录后,您可以切换到应用程序目录并直接查看所有 log/config 个文件。

当您 git push 更改您的应用程序时,您的 OpenShift 会响应有关 setup.py、requirements.txt 等状态的详细输出。这是部署的示例(缩写)输出到 OpenShift 上的 Python 应用:

$ git commit -m "Adds BeautifulSoup"
$ git push
Counting objects: 3, done.
...
remote: Stopping Python 3.3 cartridge
remote: Waiting for stop to finish
...
remote: Building git ref 'master', commit 8d92954
remote: Activating virtenv
remote: Checking for pip dependency listed in requirements.txt file..
...
remote: Collecting beautifulsoup4 (from -r /var/lib/openshift/553fde444382eca8a0000028/app-root/runtime/repo/requirements.txt (line 1))
...
remote: Downloading http://mirror1.ops.rhcloud.com/mirror/python/web/packages/source/b/beautifulsoup4/beautifulsoup4-4.3.2.tar.gz (143kB)
remote: Installing collected packages: beautifulsoup4
remote: Running setup.py install for beautifulsoup4
remote: Successfully installed beautifulsoup4-4.3.2
remote: Running setup.py script..
remote: running develop
remote: running egg_info
remote: creating YourAppName.egg-info
remote: writing top-level names to YourAppName.egg-info/top_level.txt
remote: writing YourAppName.egg-info/PKG-INFO
remote: writing dependency_links to YourAppName.egg-info/dependency_links.txt
remote: writing manifest file 'YourAppName.egg-info/SOURCES.txt'
remote: running build_ext
remote: Creating /var/lib/openshift/553fde444382eca8a0000028/app-root/runtime/dependencies/python/virtenv/venv/lib/python3.3/site-packages/YourAppName.egg-link (link to .)
remote: Adding YourAppName 1.0 to easy-install.pth file
remote: Installed /var/lib/openshift/553fde444382eca8a0000028/app-root/runtime/repo
remote: Processing dependencies for YourAppName==1.0
remote: Finished processing dependencies for YourAppName==1.0
remote: Preparing build for deployment
remote: Deployment id is d9c707fb
remote: Activating deployment
remote: Starting Python 3.3 cartridge (Apache+mod_wsgi)
remote: Application directory "/" selected as DocumentRoot
remote: Application "wsgi.py" selected as default WSGI entry point
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success