0

我正在尝试将 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

我不知道为什么会这样。

4

1 回答 1

0

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

var jobs = kue.createQueue({ redis: process.env.REDIS_URL })

访问当前队列。

希望它会帮助某人。

于 2016-03-18T13:07:10.630 回答