im a big fan of simple.  On my travels I discovered a really cool GitHub repository that is perfect for someone just starting out playing with Node and cloud technology.

Effectively  it gets you going with a Node.js app that uses a MySQL database residing on BlueMix. All you have to do is upload a file of line spaced text and it will add it to MySQL. Perfect if you want to get started playing with the technology

 

Here is the link to the goodies – https://github.com/ibmjstart/bluemix-node-mysql-uploader

 

But just to give you an overview of how simple it is – ive outlined the simple steps below…

 

First things first, we need to install the cf command line tool that will be used to upload and manage your application. If you’ve previously installed an older version of the cf tool, make sure you are now using v6 of cf by passing it the -v flag:

cf -v

Steps

In the terminal, go into the directory named app, and follow these steps.

  1. Login to Bluemix.

    usage: $ cf login [-a API_URL] [-o ORG] [-s SPACE]
    example: $ cf login -a https://api.ng.bluemix.net
  2. Create an instance of the postgreSQL service, giving it a unique name in the last arguement.

    usage: $ cf create-service SERVICE PLAN SERVICE_INSTANCE
    example: $ cf create-service mysql 100 mysql_NMU
  3. From the directory that houses the app.js file (not from the root directory that contains thisREADME.md file), push the app with the –no-start option so we can bind our required service before starting. Pass the -c flag to specify the start command that should be used by CloudFoundry to run your app. Be sure to give your app a unique app name to be used for its hostname; for instance the example below would result in http://myupload-.ng.bluemix.net.

    usage: $ cf push APP [--no-manifest] [--no-start] [-c COMMAND]
    example: $ cf push myupload-<username> --no-manifest --no-start -c "node app.js"
  4. Bind the MySQL service instance to the new app

    usage: $ cf bind-service APP SERVICE_INSTANCE
    example: $ cf bind-service myupload-<username> mysql_NMU
  5. Start the app

    usage: $ cf start APP
    example: $ cf start myupload-<username>

 Enjoy!!!

Advertisements