-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b064ad1
commit 5a0d53f
Showing
163 changed files
with
14,757 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The MIT License (MIT) | ||
Copyright (c) <2012-2013> <Eric Abouaf> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,40 @@ | ||
# Moved ! | ||
# aws-swf-activities : | ||
|
||
This repository is deprecated. | ||
Collections of: | ||
|
||
* ready-to-run activities | ||
* workflows examples | ||
|
||
|
||
### New Module Ideas | ||
|
||
* merge human task and email task into one ( + provide different backends, either files or DynamoDB) | ||
|
||
* WebDriver activity (WIP) | ||
|
||
* mturk: options for the poller (WIP) | ||
|
||
* Document multi-activity package: 'ec2_runInstances' -> require('ec2').runInstances | ||
|
||
|
||
## Usage | ||
|
||
|
||
# launch 5 activity workers in the activities/ directory | ||
# and 2 decider workers in the workflows/ directory | ||
swf-toolkit -w 5 -d 2 | ||
|
||
same as | ||
|
||
cd activities | ||
swf-activity | ||
cd workflows | ||
swf-decider | ||
|
||
|
||
|
||
|
||
## License | ||
|
||
[MIT License](https://raw.github.com/neyric/aws-swf/master/LICENSE.txt) | ||
|
||
All the activities have been included into the [main aws-swf repository](https://github.com/neyric/aws-swf) ! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
exports.username = "neyric"; | ||
exports.password = 'xxxxxxxxx'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var deathbycaptcha = require('deathbycaptcha2'); | ||
|
||
exports.worker = function (task, config) { | ||
|
||
deathbycaptcha.credentials = { | ||
username: config.username, | ||
password: config.password | ||
}; | ||
|
||
var input = JSON.parse(task.config.input); | ||
|
||
deathbycaptcha.decodeUrl(input.url, 10000, function(err, result) { | ||
|
||
task.respondCompleted({captcha_text: result.text}, function (err) { | ||
if (err) { console.error(err); return; } | ||
console.log("deathbycaptcha: respondComplete"); | ||
}); | ||
|
||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name" : "deathbycaptcha", | ||
"main" : "./deathbycaptcha.js", | ||
"private": true, | ||
"dependencies": { | ||
"deathbycaptcha2": "1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
var worker = require('./deathbycaptcha').worker; | ||
|
||
var config = require('./config'); | ||
|
||
|
||
var task = { | ||
|
||
config: { | ||
input: JSON.stringify({ | ||
url: "http://upload.wikimedia.org/wikipedia/commons/b/b6/Modern-captcha.jpg" | ||
}) | ||
}, | ||
|
||
respondCompleted: function (results) { | ||
console.log("Done !"); | ||
console.log(results); | ||
} | ||
}; | ||
|
||
worker(task, config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Amazon DynamoDB activities | ||
|
||
Uses the AWS JavaScript SDK for Node.js | ||
|
||
## Documentation | ||
|
||
The full list of methods is available on : | ||
|
||
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/Client.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
exports.accessKeyId = "XXXX"; | ||
|
||
exports.secretAccessKey = "XXXX"; | ||
|
||
exports.region = 'us-east-1'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
var AWS = require('aws-sdk'); | ||
|
||
|
||
function makeFct(name) { | ||
|
||
return function (task, config) { | ||
|
||
AWS.config.update({ | ||
accessKeyId: config.accessKeyId, | ||
secretAccessKey: config.secretAccessKey, | ||
region: config.region | ||
}); | ||
|
||
var params = JSON.parse(task.config.input); | ||
|
||
var svc = new AWS.DynamoDB(); | ||
|
||
svc.client[name](params, function (err, data) { | ||
if (err) { | ||
console.log(err); // an error occurred | ||
task.respondFailed('Error during the DynamoDB call', err); | ||
|
||
} else { | ||
// successful response | ||
// console.log( JSON.stringify(data, null, 3) ); | ||
task.respondCompleted(data); | ||
} | ||
}); | ||
|
||
}; | ||
|
||
} | ||
|
||
[ | ||
"batchGetItem", | ||
"batchWriteItem", | ||
"createTable", | ||
"deleteItem", | ||
"deleteTable", | ||
"describeTable", | ||
"getItem", | ||
"listTables", | ||
"putItem", | ||
"query", | ||
"scan", | ||
"updateItem", | ||
"updateTable" | ||
].forEach(function(n) { | ||
exports[n] = makeFct(n); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name" : "dynamodb", | ||
"main" : "./dynamodb.js", | ||
"version": "0.0.1", | ||
"private": true, | ||
"dependencies": { | ||
"aws-sdk": "0.9.1-pre.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
var worker = require('./dynamodb').listTables; | ||
|
||
var config = require('./config'); | ||
|
||
var task = { | ||
|
||
config: { | ||
input: JSON.stringify({ | ||
}) | ||
}, | ||
|
||
respondCompleted: function (results) { | ||
console.log("Done !"); | ||
console.log(JSON.stringify(results, null, 3) ); | ||
} | ||
|
||
}; | ||
|
||
worker(task, config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Amazon EC2 activities | ||
|
||
Uses the AWS JavaScript SDK for Node.js | ||
|
||
## Documentation | ||
|
||
The full list of methods is available on : | ||
|
||
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2/Client.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
|
||
/* | ||
# Ouvrir une session SSH : | ||
ssh -i ~/.ec2/quickflow.pem bitnami@ec2-23-20-110-171.compute-1.amazonaws.com | ||
# Pour lancer une commande : | ||
ssh -i ~/.ec2/quickflow.pem bitnami@ec2-23-20-110-171.compute-1.amazonaws.com 'uptime' | ||
# USER DATA : | ||
GET http://169.254.169.254/2007-03-01/user-data | ||
*/ | ||
|
||
// TODO: make default duration of the task much longer ! | ||
|
||
|
||
exports.worker = function(task, input, cb) { | ||
|
||
var ec2 = aws.createEC2Client(yourAccessKeyId, yourSecretAccessKey); | ||
|
||
function pollCheckRunning(instanceId, interval) { | ||
|
||
ec2.call("DescribeInstances", {}, function(err, result) { | ||
|
||
if(err) { cb(err); return; } | ||
|
||
var allInstances = []; | ||
|
||
// XML to JSON conversion is bad on arrays | ||
var reservationSets = result.reservationSet.item; | ||
if( !Array.isArray(reservationSets) ) reservationSets = [reservationSets]; | ||
|
||
reservationSets.forEach(function(r) { | ||
var instances = r.instancesSet.item; | ||
if( !Array.isArray(instances) ) r.instancesSet.item = [r.instancesSet.item]; | ||
allInstances = allInstances.concat(instances); | ||
}); | ||
|
||
var instances = allInstances.filter(function(i){return i.instanceId==instanceId;}) | ||
if(instances.length != 1) { | ||
console.log("bouhh..."); | ||
} | ||
|
||
var instance = instances[0]; | ||
|
||
console.log(instance.instanceState.name); | ||
|
||
if(instance.instanceState.name == "running") { | ||
console.log("EC2 instance running !"); | ||
|
||
clearInterval(interval); | ||
|
||
cb(null, {instanceId: instanceId, instance: instance}); | ||
|
||
} | ||
}); | ||
|
||
}; | ||
|
||
var instanceId, | ||
reservationId; | ||
ec2.call("RunInstances", { | ||
ImageId: input.ImageId, | ||
MinCount: 1, | ||
MaxCount: 1, | ||
|
||
UserData: "This is some cool user data\nOuyeah\n", | ||
InstanceType: "m1.small", | ||
|
||
KeyName: "quickflow", | ||
|
||
"SecurityGroup.0": "quick-start-1" | ||
|
||
|
||
}, function (err, response) { | ||
|
||
if(err) { cb(err); return; } | ||
|
||
console.log("Instance created !"); | ||
console.log( response ); | ||
|
||
reservationId = response.reservationId; | ||
instanceId = response.instancesSet.item.instanceId; | ||
|
||
var interval = setInterval(function() { | ||
pollCheckRunning(instanceId, interval); | ||
}, 5000); | ||
|
||
}); | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
exports.accessKeyId = "XXXX"; | ||
|
||
exports.secretAccessKey = "XXXX"; | ||
|
||
exports.region = 'us-east-1'; |
Oops, something went wrong.