Skip to content

Instantly share code, notes, and snippets.

@siroken3
Created January 18, 2015 15:21
Show Gist options
  • Save siroken3/d7beb597b4f169a02bbe to your computer and use it in GitHub Desktop.
Save siroken3/d7beb597b4f169a02bbe to your computer and use it in GitHub Desktop.
asyncによる配列データからのシーケンシャル実行
var async = require('async');
var exec =require('child_process').exec
var plays = []
var datum = ["hello", "world"]
var cmd = function (msg, logger) {
var command = "echo " + msg + "; sleep 10"
var proc = exec(command,
{
timeout: 3600 * 1000
},
logger
)
}
async.mapSeries(datum, function(data, next) {
console.log(new Date())
cmd(data, function(error, stdout, stderr) {
console.log(stdout)
next(null, stdout)
})
},
function(error, results) {
console.log('all done.')
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment