Kue 崩溃解析服务器
Posted
技术标签:
【中文标题】Kue 崩溃解析服务器【英文标题】:Kue crashes parse server 【发布时间】:2016-03-17 16:31:42 【问题描述】:我正在尝试将 kue 用于我的 Parse 服务器(托管在 heroku 上)上的预定作业。现在我已经修改了我的index.js
文件,就像我发现的关于 Kue 的几个教程中所述:
var express = require('express')
, kue = require('due')
, redis = require('redis');
var ParseServer = require('parse-server').ParseServer;
var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI;
if (!databaseUri)
console.log('DATABASE_URI not specified, falling back to localhost.');
var api = new ParseServer(
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || '',
serverURL: process.env.SERVER_URL
);
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey
// connect to REDIS
var client = redis.createClient(process.env.REDIS_URL);
var app = express();
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api)
.use(kue.app); // wire up Kue (see /active for queue interface)
// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res)
res.status(200).send('I dream of being a web site.');
);
var port = process.env.PORT || 1337;
app.listen(port, function()
console.log('parse-server-example running on port ' + port + '.');
);
我发现应用程序在以下行崩溃:.use(kue.app)
。这是我得到的错误:
Starting process with command `node index.js`
parse-server-example running on port 22995.
/app/node_modules/parse-server/lib/index.js:298
throw err;
^
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at Object.exports._errnoException (util.js:890:11)
at exports._exceptionWithHostPort (util.js:913:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1057:14)
Process exited with status 7
State changed from starting to crashed
我不知道为什么会这样。
【问题讨论】:
您好!您最近在 Parse Server Platform 上评论了有关如何使用 kue 进行预定推送通知的问题。我一直在尝试实施它们,但没有成功。你介意看看我的question吗?谢谢!!! 【参考方案1】:可以删除行:.use(ku.app)
。所需要的只是添加:
var jobs = kue.createQueue( redis: process.env.REDIS_URL )
访问当前队列。
希望它对某人有所帮助。
【讨论】:
以上是关于Kue 崩溃解析服务器的主要内容,如果未能解决你的问题,请参考以下文章