Customize the application

  1. Create a manifest.yml file. Put this file in the project directory, which is the directory where your file is stored.
  2. Add the following information to your manifest.yml file. In this example, the application is called sc-proj-watson, but you must select a unique name. This information also specifies a buildpack and a Cloud Foundry stack. (A stack is a prebuilt root file system (roots) that works in tandem with a buildpack and is used to support running applications.) Check that the combination of the Python runtime and stack is supported by your buildpack.

    - path: .
    memory: 128M
    instances: 1
    name: sc-proj-watson
    host: sc-proj-watson
    disk_quota: 1024M
    - cflinuxfs2
    command: bash ./

    In the code above, notice the line with the command: bash ./ This line launches the application. This mechanism will give you greater flexibility in running other commands, in particular, the Python shell. In this lab, you will use the command-line option.
    You can start the application on Bluemix in this way if you want greater flexibility in running other commands such as the Python shell.
    If you base your application code on the boilerplate sample from Bluemix, notice that the manifest.yml file doesn’t have a corresponding command. Instead, it uses a Procfile to specify how to launch your application. You can use either method. Some developers prefer the bash command line.
    If you use a bash shell file, be sure to save it in a UNIX format:

    if [ -z "$VCAP_APP_PORT" ];
    then SERVER_PORT=80;
    echo port is $SERVER_PORT
    python makemigrations
    python migrate
    python shell <

    echo [$0] Starting Django Server…
    python runserver$SERVER_PORT –noreload

    The following line runs the Python procedure that initializes the database:
    python shell <

  3. Create this file ( in the same directory as the file:from createdbadmin import MainProgramgo = MainProgram()

    This in turn needs a file named, which is also in the same directory as the file.

    # -*- coding: utf-8 -*-

    from django.contrib.auth.models import User

    from django.db.utils import IntegrityError

    import logging

    logger = logging.getLogger(__name__)

    class MainProgram(object):

    def __init__(self):

    User.objects.create_superuser(username='xxx',password='yyy',email='[email protected]')

    except IntegrityError as e:

    logger.warning("DB Error Thrown %s" % e)

    After the administrator account is created, running this command subsequent times will throw an exception that will be caught, and the application can start.