Created
January 18, 2015 15:21
-
-
Save siroken3/d7beb597b4f169a02bbe to your computer and use it in GitHub Desktop.
asyncによる配列データからのシーケンシャル実行
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
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