【问题标题】:python scheduler on bluemixbluemix 上的 python 调度程序
【发布时间】:2018-05-22 08:52:25
【问题描述】:

我在 python 中使用 schedule 包,每 15 秒调用一次函数,并希望在 IBM Bluemix 上运行此代码。 已使用 -no-route 选项将应用程序推送到 Bluemix,虽然应用程序已部署到 Bluemix,但 Bluemix 无法启动应用程序

下面是我试过的示例代码

import schedule
import time

def printMyName():
    print("NAME...")

schedule.every(15).seconds.do(printMyName)


while 1:
   schedule.run_pending()
   time.sleep(10)

Bluemix 日志中此应用程序的消息:

Destroying container
Successfully destroyed container

0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting

过了一会儿,我在日志中看到了这条消息

ERR Timed out after 1m0s: health check never passed.

Python 版本:3.4.4

【问题讨论】:

    标签: python-3.x ibm-cloud openwhisk ibm-cloud-functions


    【解决方案1】:

    我通过设置让我的调度器工作

    health-check-type: process
    

    有关这方面的 Cloud Foundry 文档在这里:https://docs.cloudfoundry.org/devguide/deploy-apps/healthchecks.html#types

    我的项目在这里:https://github.com/snowch/bluemix_retail_demo/tree/master/messagehub2elasticsearch/purge_old_indices

    【讨论】:

      【解决方案2】:

      我已经完成了something similar with schedule a while back 并且成功了。拥有no-route option set in the manifest 对我有用。

      今天,我建议看看IBM Cloud Functions / OpenWhisk 和alarm packageIBM Cloud Functions allows actions to be written in Python。使用警报,您可以以类似 cron 的方式调用这些 Python 函数,而且成本可能更低。

      【讨论】:

      • 尝试将 no-route 放在清单中,但没有帮助,仍然是相同的行为。并且查看了你的博客,git中的源代码看起来你没有使用过Procfile。但对我来说,如果我尝试在没有 Procfile 的情况下进行推送,我会收到一条消息,要求我提供文件。您是否使用了任何特定的 buildpack?
      • 健康检查类型是我测试后引入的。现在需要使用它。但是,我仍然建议使用 IBM Cloud Functions。您不需要自己的服务器来处理类似 cron 的事件。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-19
      • 1970-01-01
      • 2016-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多