简体   繁体   中英

Node.js app on openshift

I have issues with an express application that works fine locally

node server.js

but has this error on openshift:

...

    Uninitialized option at server.js:104:9 events.js:72
    throw er; // Unhandled 'error' event
          ^
    Error: listen EACCES
    at errnoException (net.js:901:11)
    at Server._listen2 (net.js:1020:19)
...

I have understood that this would be an issue with my .createServer().listen implementation. My code is:

var express = require('express');
var path = require('path');
....//I cut code from here..Bunch of middleware..
var https = require('https');
var http = require('http');

....//My routes were here...
var app = express();

//HTTP
var server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
http.createServer(app).listen(server_port);

var ssl = {
key: fs.readFileSync('keys/key.pem'),
cert: fs.readFileSync('keys/cert.pem')
};

https.createServer(ssl, app).listen(443);

I'd also like to have working ssl, but i couldn't find info on that.

server = require('http').createServer(app)

port = process.env.OPENSHIFT_NODEJS_PORT || 8080  
ip = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";

server.listen(port, ip);

Has always worked for me in the past. I'm not entirely confident that rearranging the stuff you have to match (since yours is almost identical) but its how I have it working in my current nodejs app. Also, for further context can you paste in the lines from Uninitialized option at server.js:104:9 events.js:72, if you've done so already can you mark them? from what I can see your stuff should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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