1

I am using the schedule package in python, to invoke a function for every 15 seconds, and want to run this code on IBM Bluemix. Have pushed the application using the -no-route option to Bluemix, though the application is deployed to Bluemix, Bluemix is not able to start the application

Below is the sample code that I tried

import schedule
import time

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

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


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

Messages in the Bluemix logs for this application:

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

And after a while, I see this message in the logs

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

Python version: 3.4.4

data_henrik
  • 16,724
  • 2
  • 28
  • 49
aryanRaj_kary
  • 503
  • 2
  • 7
  • 28

2 Answers2

1

I have done something similar with schedule a while back and it worked. Having the no-route option set in the manifest did the trick for me.

Today, I would recommend to take a look at IBM Cloud Functions / OpenWhisk and the alarm package. IBM Cloud Functions allows actions to be written in Python. With the alarms you can invoke those Python functions in a cron-like fashion - and likely with less cost.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
  • Tried putting the no-route in the manifest, but didn't help, still same behaviour. And have checked your blog, and the source code in git looks like you haven't used Procfile. But for me, If I try to push without Procfile, I get a message asking me to provide the file. Were you using any specific buildpack? – aryanRaj_kary Dec 09 '17 at 04:45
  • The health check type was introduced after I tested mine. It needs to be used now. However, I keep my recommendation of using IBM Cloud Functions. You don't need your own server for cron-like events. – data_henrik Dec 10 '17 at 11:12
1

I got my scheduler to work by setting

health-check-type: process

The cloud foundry docs on this are here: https://docs.cloudfoundry.org/devguide/deploy-apps/healthchecks.html#types

My project is here: https://github.com/snowch/bluemix_retail_demo/tree/master/messagehub2elasticsearch/purge_old_indices

Chris Snow
  • 23,813
  • 35
  • 144
  • 309