A Fork Task implements a simple task from an existing fork object.
The Fork task:
//task.js
process.send('start')
This would be the task worker:
//worker.js
var ForkTask = require('relieve/tasks/ForkTask')
var fork = require('child_process').fork
var task_fork = fork('task.js')
task = new ForkTask(task_fork)
task.name = 'MyForkTask'
task.once('start', function() {
//task started
})
Another example using IPCEE to ease the communication:
//task.js
var IPCEE = require('relieve/IPCEE')
var ipc = IPCEE(process)
ipc.on('thank', function(person) {
if(person == 'you')
ipc.send('you', 'welcome')
})
The worker:
//worker.js
var ForkTask = require('relieve/tasks/ForkTask')
var fork = require('child_process').fork
task = new ForkTask(fork('task.js'))
//wrapper.js
task.send('thank', 'you')
task.once('you', function(data) {
//data is welcome
})