Answer the question
In order to leave comments, you need to log in
Working with queues with npm - the kue module. Did I understand the meaning correctly?
I am building a web application using Express. Using the phantomjs module, I take screenshots of the site (in the child script 'phantom-script.js'), then from these images, by calling the generate_video function, I create a video.
app.get('/', function (req, res) {
var url = req.query.presentation;
var reg_url_base = new RegExp("http/");
//name of folder where will save screensots of site
var name_folder = url.replace(reg_url_base, '');
var type = req.query.format;
var childArgs = [
path.join(__dirname, 'phantom-script.js'),
duration,
url,
FPS,
name_folder
]
childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
generate_video(res,type,name_folder);
})
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
function generate_video(res,type,name_folder){
////код создания видео, неважно
res.json('Файл создавался ' + function_time + 'ms' + ', ' + 'местоположение: video_output/' + name_folder+'.' + type);
}
app.get('/', function (req, res) {
/*............*/
childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
var job_video_creationg = queue.create('video_creating', {
title: 'creating_video',
}).save( function(err){
if(err) console.log( 'error in creating of job with id' + job_video_creationg.id );
});
queue.process('video_creating', 200, function(job_video_creationg, done){
generate_video(res,type,name_folder, done);
});
})
});
function generate_video(res,type,name_folder, done){
//генерация видео
res.json('Файл создавался ' + function_time + 'ms' + ', ' + 'местоположение: video_output/' + name_folder+'.' + type);
done();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question