- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 kue 对一些使用 node express 的 python 作业进行排队和处理。我使用的 redis 服务器不是 localhost 上的默认服务器,而是 AWS Redis。问题陈述:与 AWS redis 的连接成功,正在创建和处理作业,正在按预期从 python 作业生成输出文件,但是当使用的服务器是 AWS Redis 时,Kue JSON API 不会返回任何数据。如果它是本地主机上的 redis 服务器,API 会完美地返回数据。
1.这是我从节点到redis的连接代码
const redisclient = redis.createClient({host: hostname, port: 6379});
var kue = require('kue'), queue = kue.createQueue({
prefix: 'q',
redis: {
port: 6379,
host: hostname,
options: {
disableSearch: false,
client: redisclient
}
}
});//redis connection works AWS
2.为 Express 安装 Kue UI
var kueUiExpress = require('kue-ui-express');
kueUiExpress(app, '/kue/', '/kue-api/');
app.use('/kue-api/', kue.app);
3.作业队列和进程调用
var suspendusershdl = queue.create('suspendusershdl', {username: currentuseremail, title: "Generate HDL file to Suspend Users", inputfile: inputfilepathname, inputcoll: collname, outputfile: outputfilepathname , pythonscript: 'suspendusershdl.py' });
suspendusershdl.searchKeys( ['username'], 'username' ).save(); //indexing by username
suspendusershdl.on('complete', function(result){
console.log('Job is now complete');
console.log('Job Details:', suspendusershdl);
//Additional logic when job is complete
});
queue.process('suspendusershdl', function(suspendusershdl, done){
//process the job, processing logic here
});
4.这是我此时看到的。如果我转到 Kue UI,所有工作详细信息都会按预期显示。
5.这是我在 AWS Redis 实例的 redis-cli 上的 MONITOR 上看到的。
1524582499.883115 [0 172.31.31.246:53372] "incr" "q:ids"
1524582499.887225 [0 172.31.31.246:53372] "hset" "q:job:3" "max_attempts" "1"
1524582499.887273 [0 172.31.31.246:53372] "sadd" "q:job:types" "suspendusershdl"
1524582499.887448 [0 172.31.31.246:53372] "hset" "q:job:3" "type" "suspendusershdl"
1524582499.887462 [0 172.31.31.246:53372] "hset" "q:job:3" "created_at" "1524582499888"
1524582499.887470 [0 172.31.31.246:53372] "hset" "q:job:3" "promote_at" "1524582499888"
1524582499.887679 [0 172.31.31.246:53372] "hset" "q:job:3" "updated_at" "1524582499888"
1524582499.887951 [0 172.31.31.246:53372] "hset" "q:job:3" "priority" "0"
1524582499.888013 [0 172.31.31.246:53372] "zadd" "q:jobs" "0" "01|3"
1524582499.888069 [0 172.31.31.246:53372] "hset" "q:job:3" "data" "{\"username\":\"abc@company.com\",\"title\":\"Generate HDL file to Suspend Users\",\"inputfile\":\"inputfilepathname",\"inputcoll\":\"suspendusers1524582499883\",\"outputfile\":\"outputfilepathname\",\"pythonscript\":\"suspendusershdl.py\"}"
1524582499.889688 [0 172.31.31.246:53372] "hset" "q:job:3" "updated_at" "1524582499890"
1524582499.889806 [0 172.31.31.246:53372] "multi"
1524582499.889816 [0 172.31.31.246:53372] "hset" "q:job:3" "state" "inactive"
1524582499.889822 [0 172.31.31.246:53372] "zadd" "q:jobs:inactive" "0" "01|3"
1524582499.889829 [0 172.31.31.246:53372] "zadd" "q:jobs:suspendusershdl:inactive" "0" "01|3"
1524582499.889836 [0 172.31.31.246:53372] "lpush" "q:suspendusershdl:jobs" "1"
1524582499.889844 [0 172.31.31.246:53372] "exec"
1524582499.941285 [0 172.31.31.246:53398] "info"
1524582499.941381 [0 172.31.31.246:53400] "info"
1524582499.941507 [0 172.31.31.246:53402] "info"
1524582499.943331 [0 172.31.31.246:53398] "select" "0"
1524582499.943340 [0 172.31.31.246:53398] "blpop" "q:suspendusershdl:jobs" "0"
1524582499.943541 [0 172.31.31.246:53400] "select" "0"
1524582499.943780 [0 172.31.31.246:53402] "select" "0"
1524582499.944132 [0 172.31.31.246:53402] "publish" "q:events" "{\"id\":3,\"event\":\"enqueue\",\"args\":[\"enqueue\",\"suspendusershdl\"]}"
1524582499.945201 [0 172.31.31.246:53372] "multi"
1524582499.945211 [0 172.31.31.246:53372] "zrange" "q:jobs:suspendusershdl:inactive" "0" "0"
1524582499.945220 [0 172.31.31.246:53372] "zremrangebyrank" "q:jobs:suspendusershdl:inactive" "0" "0"
1524582499.945229 [0 172.31.31.246:53372] "exec"
1524582499.947129 [0 172.31.31.246:53402] "hgetall" "q:job:3"
1524582499.949203 [0 172.31.31.246:53372] "hset" "q:job:3" "started_at" "1524582499949"
1524582499.949298 [0 172.31.31.246:53372] "hset" "q:job:3" "workerId" "kue:ip-172-31-31-246:10624:suspendusershdl:1"
1524582499.949467 [0 172.31.31.246:53372] "hset" "q:job:3" "updated_at" "1524582499950"
1524582499.949550 [0 172.31.31.246:53372] "multi"
1524582499.949563 [0 172.31.31.246:53372] "zrem" "q:jobs:inactive" "01|3"
1524582499.949570 [0 172.31.31.246:53372] "zrem" "q:jobs:suspendusershdl:inactive" "01|3"
1524582499.949575 [0 172.31.31.246:53372] "hset" "q:job:3" "state" "active"
1524582499.949580 [0 172.31.31.246:53372] "zadd" "q:jobs:active" "0" "01|3"
1524582499.949596 [0 172.31.31.246:53372] "zadd" "q:jobs:suspendusershdl:active" "0" "01|3"
1524582499.949603 [0 172.31.31.246:53372] "zadd" "q:jobs:active" "0" "01|3"
1524582499.949608 [0 172.31.31.246:53372] "exec"
1524582499.951338 [0 172.31.31.246:53402] "publish" "q:events" "{\"id\":3,\"event\":\"start\",\"args\":[\"start\",\"suspendusershdl\",null]}"
1524582500.005064 [0 172.31.31.246:53372] "rpush" "q:job:3:log" "File Imported Successfully to MongoDB"
1524582500.005121 [0 172.31.31.246:53372] "hset" "q:job:3" "updated_at" "1524582500005"
1524582500.005188 [0 172.31.31.246:53372] "rpush" "q:job:3:log" "Calling Exec Python"
1524582500.005225 [0 172.31.31.246:53372] "hset" "q:job:3" "updated_at" "1524582500005"
1524582500.138182 [0 172.31.31.246:53390] "multi"
1524582500.138202 [0 172.31.31.246:53390] "zinterstore" "q:searchtmpkey" "3" "q:search:word:HLTMN" "q:search:word:RSP" "q:search:word:KM"
1524582500.138219 [0 172.31.31.246:53390] "zrevrange" "q:searchtmpkey" "0" "-1"
1524582500.138224 [0 172.31.31.246:53390] "zremrangebyrank" "q:searchtmpkey" "0" "-1"
1524582500.138230 [0 172.31.31.246:53390] "exec"
1524582500.620289 [0 172.31.31.246:53372] "rpush" "q:job:3:log" "suspendusershdl.py completed successfully."
1524582500.620317 [0 172.31.31.246:53372] "hset" "q:job:3" "updated_at" "1524582500620"
1524582500.620497 [0 172.31.31.246:53372] "hset" "q:job:3" "duration" "672"
1524582500.620592 [0 172.31.31.246:53372] "hset" "q:job:3" "progress" "100"
1524582500.620684 [0 172.31.31.246:53372] "hset" "q:job:3" "updated_at" "1524582500621"
1524582500.620779 [0 172.31.31.246:53372] "multi"
1524582500.620792 [0 172.31.31.246:53372] "zrem" "q:jobs:active" "01|3"
1524582500.620799 [0 172.31.31.246:53372] "zrem" "q:jobs:suspendusershdl:active" "01|3"
1524582500.620806 [0 172.31.31.246:53372] "hset" "q:job:3" "state" "complete"
1524582500.620811 [0 172.31.31.246:53372] "zadd" "q:jobs:complete" "0" "01|3"
1524582500.620821 [0 172.31.31.246:53372] "zadd" "q:jobs:suspendusershdl:complete" "0" "01|3"
1524582500.620828 [0 172.31.31.246:53372] "exec"
1524582500.622509 [0 172.31.31.246:53372] "hincrby" "q:job:3" "attempts" "1"
1524582500.624102 [0 172.31.31.246:53402] "publish" "q:events" "{\"id\":3,\"event\":\"complete\",\"args\":[\"complete\",null,null]}"
1524582500.624224 [0 172.31.31.246:53372] "incrby" "q:stats:work-time" "672"
1524582500.624382 [0 172.31.31.246:53398] "blpop" "q:suspendusershdl:jobs" "0"
1524582500.887372 [0 172.31.31.246:53400] "set" "promotion:lock" "U3dicEfREeiGI0kMM36BPg==" "PX" "2000" "NX"
1524582500.887552 [0 172.31.31.246:53400] "set" "activeJobsTTL:lock" "U3eJgEfREeiGI0kMM36BPg==" "PX" "2000" "NX"
1524582500.889253 [0 172.31.31.246:53372] "zrangebyscore" "q:jobs:delayed" "0" "1524582500889" "LIMIT" "0" "1000"
1524582500.889452 [0 172.31.31.246:53372] "zrangebyscore" "q:jobs:active" "100000" "1524582500890" "LIMIT" "0" "1000"
1524582500.892561 [0 172.31.31.246:53400] "script" "load" "--\n-- Delete a key if content is equal\n--\n-- KEYS[1] - key\n-- KEYS[2] - content\nlocal key = KEYS[1]\nlocal content = ARGV[1]\n\nlocal value = redis.call('get', key)\n\nif value == content then\n return redis.call('del', key);\nend\n\nreturn 0\n"
6.到目前为止一切顺利。现在我调用 JSON API 来查询用户安排的所有作业。
request({'rejectUnauthorized': false, 'url': 'https://example.com/kue-api/job/search?q=' + currentuseremail, 'method': 'GET'}, function(error, response, body) {
if (error) {
console.log(error);
res.json({ success : false, message : 'Error', jobs: processesfromkue});
} else {
processesfromkue = JSON.parse(body);
console.log('Number of processes in kue for user: ', processesfromkue.length);
res.json({ success : true, message : 'Kue Jobs retrieved', jobs: processesfromkue}); //This API Call always results in success and the array of jobs returned is empty although there are jobs displayed in the DB and UI
}
});
如果我在本地主机上使用默认的 redis,此 API 调用将返回数据。
我可以做些什么来让 JSON API 从 AWS Redis 返回数据?如果我必须在本地主机上使用 redis-server 并且在连接到 AWS Redis 时 JSON API 的这种行为仍然存在,我就无法转移到 Prod。
感谢您的帮助。
最佳答案
您确定您的 Redis 实例与您的 Kue/Node 服务器位于同一 VPC 中吗?
测试与 aws redis 的连接的一种方法是登录服务器或同一 VPC 中的服务器。安装 redis-cli 并测试连接。
您可以使用以下命令安装 redis-cli:
yum install libjemalloc1 libjemalloc-dev gcc make -y
cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
cp src/redis-cli /usr/local/bin/
chmod 755 /usr/local/bin/redis-cli
重新登录,然后:
测试连接:
redis-cli -c -h REDIS.URL.cache.amazonaws.com -p 6379
关于redis - Kue JSON API 不返回任何数据 - KUE with AWS Redis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50006249/
我正在使用 kue 对一些使用 node express 的 python 作业进行排队和处理。我使用的 redis 服务器不是 localhost 上的默认服务器,而是 AWS Redis。问题陈述
我希望我的 queue.process 函数在一个单独的文件中,但是 module.exports 不起作用。 kue.js: var kue = require('kue'); module.exp
我正在使用 kue在我的一个项目中,从数据库中删除陈旧的锁。我能够处理单个作业,例如更新 mongoDB 中的单个文档。 var kue = require('kue') , queue = kue
当在具有多个实例(例如 docker 中的多个容器)的应用程序中使用 kue 时,所有实例都使用相同的 redis 数据库,如果您暂停一个工作程序,您是否需要在所有实例上暂停该工作程序,或者是在 re
我有一个用 Heroku 部署的解析服务器(来 self 的 GitHub 存储库)并由 mongoLab 托管。我正在尝试在我的应用程序中发送预定的推送通知,kue 似乎是最可行的选择。然而,由于我
是否有已知的 API 可以获取 Kue 中的工作数量?例如,我想获取非事件作业的数量。 现在我有这部分获取工作的代码。 var kue = require('kue'), jobs = kue.cre
我正在尝试按不同的时间表运行两个不同的作业(请参阅下面的代码示例)。由于某种原因,本应每天晚上 11 点运行一次的作业每次运行时都会运行其他作业。当我期望它们运行时,如何让它们运行?感谢您的帮助。 c
我的主 Node 实例派生了一个工作进程,该进程通过 IPC 接受消息(使用内置 Node process.send() 和 process.on('message'... ),这些对象包含有关要添加
我不太确定如何解决这个问题,但这对我来说很烦人,而且在生产中把事情搞砸了。我正在使用 kue.js 在用户完成某事后完成任务。我网站上最典型的案例是上传图片和发送电子邮件。 它大部分时间都有效,但其他
我正在运行一个 heroku 应用程序,后台工作人员使用 Kue 处理作业。因为 heroku 终止并重新启动任何需要超过 30 秒的请求,所以我最终在 jobs.create() 上(在完成之前)将
我有一个 API 端点,它提供来自 MongoDB 的一些 JSON。就像这样: router.get('/api/links', function (req, res) { // Find ex
持续处理添加到队列中的项目的最佳方法是什么?我看到下面的方法 queue.process https://github.com/Automattic/kue#processing-jobs 但这将处理
根据 kue 文档,创建队列和添加作业很容易,但我无法了解作业的存储方式 var kue = require('kue') jobs = kue.createQueue(); 添加工作 jobs.
我的应用使用 Kue排队请求,这些请求由 worker.js 处理,因为我需要通过 Proximo 发送作业发出的请求 - 这有点令人困惑。但正因为如此,作业的结果无法发送回用户。以前,作业会res.
如果系统中已有相同的作业,我希望 jobs.create 失败。有什么办法可以做到这一点? 我需要每 24 小时运行一次相同的作业,但有些作业可能需要超过 24 小时,因此在添加之前我需要确保该作业不
使用 Kue ,如何安排每周四执行一次的工作? Kue readme 提到我可以延迟一个 Job,但是在特定时间重复执行 Job 呢? 我可以通过 cron 作业做我想做的事,但我喜欢 Kue 的功能
我正在使用 kue在一个网络爬虫应用程序中。如果错误符合特定条件,我想为某些失败的作业设置 attempts。例如,如果错误是由套接字挂起引起的,则作业将以 1 分钟的间隔重试 3 次。 我的代码如下
我正在使用 kue对于我的作业队列,我想在不使用 GUI 的情况下知道还剩下多少作业,有多少作业失败等。如何检索此类信息? 例如,在开始处理作业队列几分钟后,我想将迄今为止失败的所有作业的状态更新为“
我正在使用 kue对于我的 node.js 应用程序中的延迟作业。 我有一些问题要弄清楚如何使用 kue 的 API 重新启 Action 业,而无需使用 redis 命令手动将作业的 id 从失败作
我创建了一个工作: var kue = require('kue'); var queue = kue.createQueue(); //name of the queue is myQueue va
我是一名优秀的程序员,十分优秀!