Frok Zapaan Frok Zapaan - 1 year ago 152
Python Question

How to run background processes on Bluemix?

I'm trying to get a really simple python program to run as a background process on IBM Bluemix as a CloudFoundry app.

I've put it in a Github repo.
There's a one-line req file because I find it easier than a and the python buildpack needs it to run.

My complete use-case is that I have an API written with Django and I need an MQTT client that will run besides it to collect data from a broker (something with Watson IOT I think).

I've tried to run both in the same CF app with a 2-lines Procfile looking like this :

web: gunicorn -e conf.wsgi --workers 2
worker: python

but the second process was just ignored.

I've also tried in the current configuration, but with a Procfile containing only the second line and it was telling me that it couldn't find the start command.

Now, with start command in the Manifest and
, either it doesn't pass the health check, or it just wait at the starting step until I get this error :

WebsocketListener.Start: Error connecting to a doppler server
proxy: error connecting to dial tcp getsockopt: connection refused

So, is there a way to run background tasks in Bluemix, if possible as standalone app (to scale and update more easily) ?

EDIT : now it works, though I haven't changed anything besides a typo to format a string in my Python script, though the app crash just about every minute

Removing crash for app with id 3978a475-4dc6-495f-9662-a6fd562dc28a

Answer Source

Short answer to the question : a separate app with the no-route argument set to true

Ok, so I've apparently got it to work fully.

I'm not sure what I've done but the problem might have come from the fact that I was asking for a 32M instance and the minimum seems to be 64M so Bluemix/CF wasn't so happy with my demand and crashed.

I was using 128M in my older tries but I think I didn't put no-route: true at the time

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download