-
Notifications
You must be signed in to change notification settings - Fork 1
/
worker.js
33 lines (24 loc) · 769 Bytes
/
worker.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
#!/usr/bin/node
var job = require( './uglify-single.js' ).uglify;
var id = process.argv[2];
const DEBUG = false;
if ( DEBUG ) {
console.log( 'worker' + id + ' started' );
}
// Get things started
process.send({ message: 'give_me_another' });
// node note: process.send sends to the master process if we were forked by
// child_process (we have an IPC channel)
process.on( 'message', function( msg ) {
if ( 'go' == msg.cmd ) {
job( msg.name, function () {
process.send({ message: 'give_me_another' });
});
} else
console.log( 'worker' + id + ': received unknown command: ' + msg.cmd );
});
process.on( 'exit', function( err ) {
if ( DEBUG ) {
console.log( 'worker' + id + ': I am exiting' );
}
});