-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprocess.js
executable file
·47 lines (32 loc) · 1.2 KB
/
process.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Take first from queue
// Put into processing as processing.jpg
// Send through meatball filter. It creates meatball.jpg
// Send through pasta filter. It creates style.jpg
// When both complete, combine into one image complete.jpg
// Delete processing and move to /complete
var fs = require('fs');
var exec = require('child_process').exec;
module.exports = function() {
var filename;
var moveQueue = function() {
var list = fs.readdirSync('./queue');
if (list.length <= 0) {
console.log('Queue empty');
return;
}
filename = list[0].split('/');
filename = filename[filename.length-1];
var file = fs.createReadStream(list[0]);
var dest = fs.createWriteStream('./processing/' + filename);
file.pipe(dest);
dest.on('end', function() { console.log('Now processing ' + filename); } );
dest.on('error', function(err) { console.log('Error copying ' + err); } );
};
var styleFile, overFile;
// Called when processes complete
var verifyComplete = function() {
console.log("Verifying");
};
var execute = function() {exec(command, function(err, stdout, stderr) { callback(stdout); })};
execute('./test.sh ./processing/' + filename, verifyComplete);
};