如何 运行 OpenShift 上的各种工作人员?

How to run various workers on OpenShift?

我有一个 Python/Flask 项目 (API),其中包含一些必须连续 运行 的工人。他们使用外部提供商 (https://redislabs.com/) 连接到 Redis。我没有找到如何为 运行 我的员工配置 Openshift。使用 Heroku 时,它很简单:

web: gunicorn wsgi --log-file -
postsearch: python manage.py worker --queue post-search
statuses: python manage.py worker --queue statuses
message: python manage.py worker --queue message
invoice: python manage.py worker --queue invoice

但是对于 Openshift,尽管用谷歌搜索了很多东西,但我找不到任何可以帮助我的东西。理想情况下,我会避免将我的应用程序部署到每个齿轮。如何使用 OpenShift 运行 多个工作人员?

OpenShift 与外部服务的集成是通过配置相关的环境变量来完成的,如下所述:https://developers.openshift.com/external-services/index.html#setting-environment-variables

Heroku 的应用程序依赖于自动配置的 REDISCLOUD_URL env var - 您需要在 OpenShift 部署中设置类似的内容,并使用来自服务仪表板的有关数据库的适用信息。

取自Getting Started with Openshift by Katie J. Miller and Steven Pousty

Cartridge

To get a gear to do anything, you need to add a cartridge. Cartridges are the plugins that house the framework or components that can be used to create and run an application. One or more cartridges run on each gear, and the same cartridge can run on many gears for clustering or scaling. There are two kind of cartridges:

Standalone

These are the languages or application server that are set up to serve your web content, such as JBoss, Tomcat, Python, or Node.js. Having one of these cartridges is sufficient to run an application.

Embedded An embedded cartridge provides functionality to enhance your application, such as database or Cron, but cannot be used on its own to create and application.

TL;DR:您必须使用墨盒来 运行 工作进程。可以找到文档 here and here, and the community-mantained examples here and a series of blog post begins here

墨盒是一堆文件和清单,让 OS 知道如何 运行 墨盒以及如何解析 deps。

但让我们构建一些东西。创建一个Django/Python app,结果是:

现在从底部的 link 或命令行工具安装您的(自定义)墨盒,您可以使用 link 到墨盒存储库。