Git Product home page Git Product logo

bluemixnodejs's Introduction

BluemixNodeJS

Deploy a Node.js Application to Bluemix

this info is used form Bluemix

Use cf buildpacks to check status of the Node.js buildpacks

$ cf buildpacks Getting buildpacks... buildpack position enabled locked
nodejs_buildpack 8 true false sdk-for-nodejs 2 true false

Use the engines section in package.json file to specify version of Node.js runtime, see following example:

{ "name": "myapp", "description": "this is my app", "version": "0.1", "engines": { "node": "0.10.26" } }

To start a local a Node.js web server , you need following code inexample.js:

var http = require('http');

var host = process.env.VCAP_APP_HOST || 'localhost'; var port = process.env.VCAP_APP_PORT || 1337

http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.end('Hello Node.js! running version ' + process.version); }).listen(port, null);

console.log('Server running at http://' + host + ':' + port + '/');

Now test example.js file locally from command line (install a node runtime to your local machine).

% node example.js Server running at http://127.0.0.1:1337/

To push Node.js application to Bluemix, use text file Procfile to describe startup command to run application. Save Procfile in root directory of application by entering following command:

web: node app.js

Here, app.js is the startup js script for your application. If Procfile is not present, the IBM Node.js buildpack checks for a scripts. start entry in the package.json file. If a start script entry is present, a Procfile is generated automatically. Otherwise, IBM Node.js buildpack checks for a server.js file in the root directory of your application. If a server.js file is found, a Procfile is also generated automatically.

{ ... "scripts": { "start": "node app.js" } }

The content of the auto-generated Procfile is shown below:

web: npm start

bluemixnodejs's People

Contributors

hansb001 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.