Skip to content

Commit

Permalink
Kill existing DynamoDBLocal before starting
Browse files Browse the repository at this point in the history
  • Loading branch information
brandongoode committed May 25, 2017
1 parent a599642 commit b156d0f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -79,4 +90,4 @@ module.exports = function(grunt) {

grunt.registerTask('coverage', ['jshint', 'dynamo:start', 'mochaTest:testCoverage', 'mochaTest:coverage', 'mochaTest:travis-cov']);

};
};

0 comments on commit b156d0f

Please sign in to comment.