Frok Zapaan Frok Zapaan - 4 months ago 40
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 setup.py 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 DJANGO_SETTINGS_MODULE=conf.dev conf.wsgi --workers 2
worker: python time.py


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
no-route
at
true
, either it doesn't pass the health check, or it just wait at the starting step until I get this error :

2016-07-22T13:10:36.671+0200
[LGR/null]
err
WebsocketListener.Start: Error connecting to a doppler server
2016-07-22T13:10:36.677+0200
[LGR/null]
err
proxy: error connecting to 159.8.128.238:8081: dial tcp 159.8.128.238:8081: 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

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