I'm building an openshift node js app which has to communicate with youtube data API. Its deployment is a success when I do "git push" with the require commented.
/*
var request = require('request');
*/
When I uncomment it, I get this error :
remote: Waiting for application port (8080) become available ...
remote: Application 'eln' failed to start (port 8080 not available)
remote: -------------------------
remote: Git Post-Receive Result: failure
remote: Activation status: failure
remote: Activation failed for the following gears:
remote: 573c3e177628e146d400004e (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/573c3e177628e146d400004e/nodejs
Am I doing it bad? How can I fix it?
thank you.
Edit 1: Adding listening code, I didn't modify it (it was already here when I've created the app).
self.ipaddress = process.env.OPENSHIFT_NODEJS_IP;
self.port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
/**
* Start the server (starts up the sample application).
*/
self.start = function()
{
// Start the app on the specific interface (and port).
self.app.listen(self.port, self.ipaddress, function()
{
console.log('%s: Node server started on %s:%d ...', Date(Date.now() ), self.ipaddress, self.port);
});
};
This is my app.js
basic code that is working on openshift.
#!/bin/env node
ipaddress = process.env.OPENSHIFT_NODEJS_IP;
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";
};
var server = app.listen(8080, ipaddress, function() {
console.log('Listening on port %d', server.address().port);
});
Can you try that?
Update
After trying it on openshift with request I also got this error but it was because package.json
didn't have request
under dependencies.
My dependencies now look like this and it works fine:
"dependencies": {
"ejs": "^2.4.1",
"express": "~3.4.4",
"request": "latest" // this is added
},
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments