问题
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 "python3 appname.py" as in Python in Linux, but neither works for me. Can anyone give me the right start command to use?
回答1:
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
回答2:
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: 1024M
domain: eu-gb.mybluemix.net
instances: 1
timeout: 120
memory: 256M
services:
- CloudAMQP-dev
- PostgreSQL-dev
applications:
- name: djangofrontend
host: djangofrontend
command: gunicorn myapp.wsgi
- name: workerbackend
host: workerbackend
no-route: true
command: python manage.py celery worker -A myapp -l debug
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.
回答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.
来源:https://stackoverflow.com/questions/30089374/what-should-the-python-start-command-look-like-in-bluemix