Skip to content

Commit

Permalink
fix(wercker): wait for MongoDB to start before starting build
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kristian Flaatten committed Jul 1, 2016
1 parent 6d6ba74 commit e4828b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 2 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const redis = require('./support/redis');
const users = require('./support/users');

before(done => mongo.on('ready', done));

beforeEach(done => redis.flushall(done));
beforeEach(done => mongo.users.drop(done));
beforeEach(done => mongo.users.insert(users, done));
beforeEach(function (done) { this.timeout(10000); mongo.db.dropDatabase(done); });
beforeEach(function (done) { this.timeout(10000); mongo.users.insert(users, done); });
4 changes: 2 additions & 2 deletions test/support/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Redis = require('ioredis');

const addr = process.env.MONGO_PORT_27017_TCP_ADDR || 'redis';
const port = process.env.MONGO_PORT_27017_TCP_PORT || '6379';
const addr = process.env.MONGO_PORT_6379_TCP_ADDR || 'redis';
const port = process.env.MONGO_PORT_6379_TCP_PORT || '6379';

module.exports = new Redis(port, addr);
7 changes: 7 additions & 0 deletions wercker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ build:
- redis:3

steps:
- script:
name: wait for MongoDB to start
code: |
apt-get update --no-install-recommends -y
apt-get install --no-install-recommends -y netcat
while ! nc -q 1 $MONGO_PORT_27017_TCP_ADDR $MONGO_PORT_27017_TCP_PORT </dev/null; do sleep 3; done
- script:
name: echo nodejs information
code: |
Expand Down

0 comments on commit e4828b7

Please sign in to comment.