현재 자신을 위해 백그라운드에서 물건을 처리해야하는 프로젝트를 진행하고 있지만 Express와 Kue 사이에서 통신해야합니다. 하지만 현재 설정에 대해 좀 더 자세히 설명해 드리겠습니다. Express.js가 호스트 컴퓨터의 CPU 절반 이상을 포크합니다. 이것은 의도 한대로 모든 것을 작동시킵니다. 이제 백그라운드 처리를 위해 kue.js를 실행하는 다른 노드 프로세스를 실행합니다. kue가 redis를 통해 작업을 예약하기 때문에 주요 문제는 처리 된 백그라운드 작업의 데이터를 메인 node.js 앱으로 다시 보낼 수있는 방법입니다.Express.js 및 Kue.js가 포함 된 클러스터
내 설치의짧은 개요 :이 같은 노드
app.js는 (노드 app.js 실행) 노드 background.js으로도 실행
var cluster = require('cluster'), Datasets = require('./models/datasets'), kue = require('kue'), jobs = cue.createQueue();
if(cluster.isMaster) {
// Forking going on here
} else {
// Express.js app runs here
app.get('/', function(req, res) {
// Now here is where i schedule the job and i would like to retrieve an answer from the job when its done, like with on('complete', ...) but that doesn't work at all
jobs.create('stuff', {lorem: 'ipsum', dolor: ''}).save();
});
}
background.js (아니다 응용 프로그램과 같은 과정)
// omiting libraries right now, its simply kue and datasets like in app.'s
jobs.process('stuff', function(job, done){
//processing some background stuff here
// Now here i would like to pass back an array of objects to the app.js process after the job is completed.
});
누구든지 이것에 대한 생각이있어? 모든 도움을 주시면 감사하겠습니다.
근, 크리스핀