Skip to content

Instantly share code, notes, and snippets.

@PieterScheffers
Created October 15, 2018 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PieterScheffers/c9d477a02f5d99e69fe4223971044239 to your computer and use it in GitHub Desktop.
Save PieterScheffers/c9d477a02f5d99e69fe4223971044239 to your computer and use it in GitHub Desktop.
Compose multiple service like docker-compose without docker
#!/bin/bash
mkdir -p logs
npm install
lerna bootstrap
# Start RabbitMQ / Redis and Mongodb
docker-compose -f docker/docker-compose.yml up -d
sleep 10
# trap 'kill 0' SIGINT
(
echo "Starting microservice_one..."
cd microservices/microservice_one
# Export all environment variables for this microservice
export PORT=7001
export MICROSERVICE_ONE_ENV=true
export NODE_ENV=development
export RABBIT_MQ_URL=amqp://guest:guest@localhost:5672
export MONGODB_URL=mongodb://localhost:27017/development
export REDIS_URL=redis://localhost
# start microservice
node_modules/.bin/nodemon src/server.js &
# redirect all output to a logfile
) | while read line; do echo "microservice_one - $line"; done > logs/microservice_one.log
(
echo "Starting microservice_two..."
cd microservices/microservice_two
# Export all environment variables for this microservice
export PORT=7002
export MICROSERVICE_TWO_ENV=true
export NODE_ENV=development
export RABBIT_MQ_URL=amqp://guest:guest@localhost:5672
export MONGODB_URL=mongodb://localhost:27017/development
export REDIS_URL=redis://localhost
# start microservice
node_modules/.bin/nodemon src/server.js &
# redirect all output to a logfile
) | while read line; do echo "microservice_two - $line"; done > logs/microservice_two.log
echo "Press ctrl-C to exit"
while sleep 10000; do true; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment