简体   繁体   English

在openshift中部署Express js应用

[英]Deploying express js app in openshift

I am trying to deploy expressjs app in openshift. 我正在尝试在openshift中部署expressjs应用程序。 In my app folder, I have copied my express js application folder. 在我的app文件夹中,我复制了我的express js application文件夹。 As per Deploying nodejs app with Open Shift PaaS , in app.js file of express application, I have added 根据使用Open Shift PaaS部署nodejs应用程序 ,在快速应用程序的app.js文件中,我添加了

app.set('port', 8080); 
app.set('ipaddr', "a.b.c.d");

Also, in package.json, I have set value of 'main' key as app.js. 另外,在package.json中,我将'main'键的值设置为app.js。 I have also changed given express version to 4.8 . 我也将给出的快速版本更改为4.8。 After pushing all the changes and node modules, when I hit my url, it says 推送所有更改和节点模块后,当我点击我的网址时,它说

Service Temporarily Unavailable 服务暂时不可用

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. 由于维护停机或容量问题,服务器暂时无法满足您的请求。 Please try again later. 请稍后再试。

Can anyone please tell me what I am missing? 谁能告诉我我想念的东西吗? AS per the error log below, sever is not reading at the given port i think: 根据下面的错误日志,服务器在我认为的给定端口没有读取:

Error: listen EACCES
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1020:19)
at listen (net.js:1061:10)
at Server.listen (net.js:1135:5)
at Object.<anonymous> (/var/lib/openshift/540091a45973ca08d9000732/app-root/runtime/repo/project1/app.js:18:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
DEBUG: Program node project1/app.js exited with code 8

I have even changed the app.js to this 我什至将app.js更改为此

var server = http.createServer(app);

server.listen(process.env.OPENSHIFT_NODEJS_PORT || 8080);

// view engine setup
app.set('views', path.join(__dirname, 'views')); 
app.set('view engine', 'ejs');
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080); 
app.set('ipaddr', process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1");

Okkk...here is what i was doing wrong.... 好吧...这是我做错了...

I needed to replace existing server listen code to this: 我需要将现有的服务器侦听代码替换为此:

 server.listen( port, ipaddress, function() {
console.log((new Date()) + ' Server is listening on port 8080');
  });

In my app.js 在我的app.js中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM