首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Kue崩溃解析服务器

Kue崩溃解析服务器
EN

Stack Overflow用户
提问于 2016-03-18 00:31:42
回答 1查看 336关注 0票数 0

我正在尝试使用kue在我的Parse Server (托管在heroku上)上执行计划的作业。现在,我已经修改了我的index.js文件,就像我找到的关于Kue的几个教程中所说的那样:

代码语言:javascript
复制
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)。下面是我得到的错误:

代码语言:javascript
复制
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

我不知道为什么会发生这种事。

EN

回答 1

Stack Overflow用户

发布于 2016-03-18 21:07:11

可以删除行:.use(ku.app)。所需要的就是添加:

代码语言:javascript
复制
var jobs = kue.createQueue({ redis: process.env.REDIS_URL })

来访问当前队列。

希望它能帮助一些人。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36066487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档