diff --git a/gruntfile.js b/gruntfile.js index eb54f5fae..e394ddafa 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -61,15 +61,26 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-mocha-test'); grunt.registerTask('dynamo:start', function() { + var getPID = 'ps aux | grep "DynamoDBLocal.jar -port ' + + DYNAMO_DB_PORT + + '" | grep -v grep | awk \'{print $2}\''; var done = this.async(); - DynamoDbLocal - .launch(DYNAMO_DB_PORT) - .then(function() { done(); }) - .catch(function(e) { done(e); }); - }); + require('child_process').exec(getPID, function (err, pid) { + if(err) { + return done(err); + } + if(pid) { + console.log('Killing DynamoDBLocal process'); + process.kill(pid); + } else { + console.log('No DynamoDBLocal process running'); + } - grunt.registerTask('dynamo:stop', function() { - DynamoDbLocal.stop(DYNAMO_DB_PORT); + DynamoDbLocal + .launch(DYNAMO_DB_PORT) + .then(function() { done(); }) + .catch(function(e) { done(e); }); + }); }); // Register the default tasks @@ -79,4 +90,4 @@ module.exports = function(grunt) { grunt.registerTask('coverage', ['jshint', 'dynamo:start', 'mochaTest:testCoverage', 'mochaTest:coverage', 'mochaTest:travis-cov']); -}; \ No newline at end of file +};