How to set up KoaJS in Openshift

I read an example on how to enable the custom version of node in openshif ( http://www.zev23.com/2014/04/openshift-harmony-nodejs.html ), so when I ssh the application that I see in the version of node (0.11.14), but when I look at the logs it says app.use(function *(){ ... SyntaxError: Unexpected token * , and I get error 503.

here is my server.js file:

 var koa = require('koa'); var app = module.exports = koa(); app.use(function *(){ this.body = 'Hello World'; }); var ipaddress = process.env.OPENSHIFT_INTERNAL_IP || process.env.OPENSHIFT_NODEJS_IP; var port = process.env.OPENSHIFT_INTERNAL_PORT || process.env.OPENSHIFT_NODEJS_PORT || 8080; if (typeof ipaddress === "undefined") { // Log errors on OpenShift but continue w/ 127.0.0.1 - this // allows us to run/test the app locally. console.warn('No OPENSHIFT_NODEJS_IP var, using 127.0.0.1'); ipaddress = "127.0.0.1"; }; if (!module.parent) app.listen(port, ipaddress); 

I also added 0.11.14 to NODEJS_VERSION inside

__ UPDATE __

I check the server using ssh, it says node 0.11.14, but when I added these lines (see below), before my actual web application starts, it will work like on node 0.10.25, and the path that was set in .bash_profile, not the one used on the way.

 var ipaddress = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1"; var port = process.env.OPENSHIFT_NODEJS_PORT || 8080; console.log(ipaddress, port); console.log(process.versions); console.log(process.env.PATH); 

Is there a way to configure PATH just before running a real application, so it will use 0.11.14 instead of 0.10.25

Thanks in advance guys

+1
source share
1 answer

I followed the instructions at https://github.com/ramr/nodejs-custom-version-openshift and now everything works. Just added main: --harmony server.js to package.json.

0
source

All Articles