我有一个可以成功部署但没有启动的 nodejs 应用程序。当我查看日志文件时,我一直收到此错误:
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
Tue Mar 29 2016 05:48:11 GMT-0400 (EDT): Node server started on 127.8.221.129:8080 ...
Server on port : 8080
Tue Mar 29 2016 05:48:11 GMT-0400 (EDT): Node server stopped.
/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/models/user.js:14
throw err;
^
Error: getaddrinfo ENOTFOUND mysql://127.8.221.130:3306/ mysql://127.8.221.130:3306/:3306
at errnoException (dns.js:26:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)
--------------------
at Protocol._enqueue (/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Protocol.handshake (/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at Connection.connect (/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/node_modules/mysql/lib/Connection.js:123:18)
at Object.<anonymous> (/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/models/user.js:12:13)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/routes/users.js:3:13)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
这是 MySQL 连接代码(密码是隐藏的,但我使用的是 MySQL 盒提供的密码,以及用户提供的密码):
var connection = mysql.createConnection({
host : 'mysql://' + process.env.OPENSHIFT_MYSQL_DB_HOST + ':' + process.env.OPENSHIFT_MYSQL_DB_PORT + '/',
user : 'adminbL38x6k',
password : '********',
database : 'addressbook'
});
connection.connect( function(err){
if (err){
throw err;
}
else {
console.log('Connected');
}
});
我也在使用 PHPmyAdmin 来创建表/管理数据库。有任何想法吗?我很绝望...谢谢!