Skip to content Skip to sidebar Skip to footer

What Should The Python Start Command Look Like In Bluemix?

I am trying to push a python3 app to Bluemix, but get the error msg 'missing start command'. I have tried to add -c 'python appname.py' as Python usually has in Windows and -c 'pyt

Solution 1:

When you push an app to Bluemix you have several options for setting your start command; you can use -c with the cf push command, you can put details into a Procfile, or you can put a command: line in your manifest.

Some documentation here: https://docs.cloudfoundry.org/devguide/deploy-apps/app-startup.html

I find the easiest is to put it in manifest.yml along with the rest of my instance configuration.

The following example creates two Python apps, both using the same code, bound to a shared postgres database and cloudamqp service. The first is a Django frontend, the second starts background celery workers:

---disk_quota:1024Mdomain:eu-gb.mybluemix.netinstances:1timeout:120memory:256Mservices:-CloudAMQP-dev-PostgreSQL-devapplications:-name:djangofrontendhost:djangofrontendcommand:gunicornmyapp.wsgi-name:workerbackendhost:workerbackendno-route:truecommand:pythonmanage.pyceleryworker-Amyapp-ldebug

It only took me half a day to figure out some of this syntax, so I hope someone apart from me finds this useful in future.

Solution 2:

You can define the start command in a file called Procfile. Create the Procfile in the root of your app code that you push to Bluemix. The contents of the Procfile should look like this:

web: python3 appname.py

where appname.py is the nameof your python script to run

Solution 3:

The Python buildpack in Bluemix defaults to python-2.7.9. You need to explicitly tell Cloud Foundry that you are using a different version of Python. To do this, add a file called runtime.txt to your app's root folder. This file's contents should simply be the Python version you are trying to use, like the following:

python-3.4.3

See here for more info: https://www.ng.bluemix.net/docs/starters/python/index.html#pythonversions

You do not need to add the start command option in your push command. However, you should have a Procfile in your app's root folder that has this start command. It should look like the following:

web: python appname.py

where appname.py is your server init file.

Post a Comment for "What Should The Python Start Command Look Like In Bluemix?"