문제

Sorry to bother you with that but I'm struggling with this almost 2 weeks now and researched a lot and didn't find any solution:

I'm trying to run a this git project < a href="https://github.com/Adrianod/Open-GPS-tracker">open gps tracker </a>, locally it runs flawlessly but when I deploy it to open shift I got the Error: EACCES I've already tried the following:

Change the server.js listening port from 8080 to an open shift variable:

var port = process.env.OPENSHIFT_NODEJS_PORT ||  process.env.OPENSHIFT_INTERNAL_PORT || 8080; 
var ipaddr = process.env.OPENSHIFT_NODEJS_IP || process.env.OPENSHIFT_INTERNAL_IP;  
var io = require('socket.io').listen(port);
var mysql = require('mysql');
var connection = mysql.createConnection({
    host     : 'myURL',
    user     : 'Myuser',
    password : 'MYpass',
    database : 'gpstracks'
});

also tried to as suggested here create a server so the socket.io will listen to it like this:

var port = process.env.OPENSHIFT_NODEJS_PORT ||  process.env.OPENSHIFT_INTERNAL_PORT || 8080; 
var ipaddr = process.env.OPENSHIFT_NODEJS_IP || process.env.OPENSHIFT_INTERNAL_IP; 
var app = require('http');
var io = require('socket.io').listen(app);
app.createServer().listen(port, ipaddr, function(){
  console.log('Express server listening on port ' + port);
});
var mysql = require('mysql');
var connection = mysql.createConnection({
    host     : 'myURL',
    user     : 'Myuser',
    password : 'MYpass',
    database : 'gpstracks'
});

When I do that I receive a different error message access denied for Myuser@MyURL then I tried to change the database information to open shift variables like this:

var port = process.env.OPENSHIFT_NODEJS_PORT ||  process.env.OPENSHIFT_INTERNAL_PORT || 8080; 
var ipaddr = process.env.OPENSHIFT_NODEJS_IP || process.env.OPENSHIFT_INTERNAL_IP; 
var app = require('http');
var io = require('socket.io').listen(app);
app.createServer().listen(port, ipaddr, function(){
  console.log('Express server listening on port ' + port);
});
var mysql = require('mysql');
var connection = mysql.createConnection({
  host     : process.env.OPENSHIFT_MYSQL_DB_HOST,
  user     : process.env.OPENSHIFT_MYSQL_DB_USERNAME,
  password : process.env.OPENSHIFT_MYSQL_DB_PASSWORD,
  database : process.env.OPENSHIFT_GEAR_NAME
});

But the issue persists.

I tried to create another user and grant all privileges but still getting the error, I also tried to npm install mysql and socket.io to both local and ssh: app-root/repo but didn't work.

I'm able to log in to my database via ssh with the user I created and password and already checked for the privileges and it has all granted. Don't know what else to do guys any help would be appreciated thanks.

도움이 되었습니까?

해결책 2

Thanks for the help but turns out that it is probably an open shift bug since i've tried with the internal variables and it did not work and when i port-forwarded, got the ip address and included it as host it worked, but it is the same ip that was showing with the variable, the port is the same either it was just a matter of inserting the numbers instead of the variables.

var port = process.env.OPENSHIFT_NODEJS_PORT ||  process.env.OPENSHIFT_INTERNAL_PORT || 8080; 
var ipaddr = process.env.OPENSHIFT_NODEJS_IP || process.env.OPENSHIFT_INTERNAL_IP; 
var app = require('http');
var io = require('socket.io').listen(app);
app.createServer().listen(port, ipaddr, function(){
  console.log('Express server listening on port ' + port);
});
var mysql = require('mysql');
var connection = mysql.createConnection({
  host     : ipFromOpenShift, //rhc port-forward <myapp>
  port     : 3306,
  user     : myUser,
  password : myPass,
  database : myDatabase
});

다른 팁

If you are using a scaled application, you also need to include the OPENSHIFT_MYSQL_DB_PORT as it does not run on port 3306

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top