如何在Openshift中设置KoaJS [英] How to setup KoaJS in Openshift
问题描述
我一直在遵循有关如何在openshif中启用自定义节点版本的示例(
I've been following the example on how to enable custom node version in openshif (http://www.zev23.com/2014/04/openshift-harmony-nodejs.html) so when I ssh to the application I can see the node version(0.11.14) installed but the when I look at the logs it says
app.use(function *(){
... SyntaxError: Unexpected token *
and I'm getting a 503 error.
这是我的server.js文件:
here's 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);
我还在
__更新__
我已经使用ssh检查了服务器,它说的是节点0.11.14,但是当我在实际的Web应用程序启动之前添加这些行(请参见下文)时,就好像它在节点0.10.25上运行并在其中设置了路径一样.bash_profile不是该路径中正在使用的那个.
I've 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 seams like it's running on node 0.10.25 and the path that was set in the .bash_profile is not the one being use in the path.
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);
是否有一种在实际应用程序启动之前配置PATH的方法,因此它将使用0.11.14而不是0.10.25
Is there a way to configure the PATH just before the actual application starts so it will use 0.11.14 instead of 0.10.25
先谢谢大家
推荐答案
我已按照 https://github.com/ramr/nodejs-custom-version-openshift ,现在一切正常.刚刚在package.json中添加了main: --harmony server.js
.
I've followed the instruction in https://github.com/ramr/nodejs-custom-version-openshift and everything is now working. Just added main: --harmony server.js
in package.json.
这篇关于如何在Openshift中设置KoaJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!