-
Notifications
You must be signed in to change notification settings - Fork 40
Create new activities
neyric edited this page Jan 13, 2013
·
4 revisions
Most of the activities expect parameters to be passed in JSON format
- name of the activity type
- main: worker module
- add dependencies
- "private": true, because those packages are not meant to be published...
exports.worker = function(task, config) {
var input_parameters = task.config.input; // or JSON.parse(task.config.input)
var result = f(input_parameters); // might be asynchronous
// Send the response to AWS SWF
task.respondCompleted(result, function(err) {
if(err) { console.error(err); return; }
console.log("echo: respondComplete");
});
};
Write config files into config.js.
They should contains private stuff: credentials, passwords, oauth token, etc...
Usually test.js
- create a decider which will just perform your task
- run a swf-activity worker
- run a swf-decider
- start your workflow
Some activities require a background deamon, which is called by an external process to mark the activity as completed.
Here are the activities which currently use a deamon :
- mturk : poll Amazon Mechanichal Turk for new assignements, and mark the activities as completed
- WebDriver : runs phantomJS in the background
- humantask : HTTP server to display the activity in a browser
To start those deamons, use the npm start command :
$ cd activities/mturk/
$ npm start
You must add the following line to your package.json if your activity requires a deamon :
"scripts": {"start": "node server.js"}