Last active
December 7, 2017 21:07
-
-
Save tylerhunt/657dc9c31644c0d0a8048945f36f7433 to your computer and use it in GitHub Desktop.
A Rakefile for trying out Citus using Docker
This file contains hidden or 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
ENV['COMPOSE_PROJECT_NAME'] ||= 'citus' | |
ENV['MASTER_EXTERNAL_PORT'] ||= '5433' | |
file 'docker-compose.yml' do | |
`curl -L https://raw.githubusercontent.com/citusdata/docker/master/docker-compose.yml > docker-compose.yml` | |
end | |
namespace :citus do | |
desc 'Start the Citus cluster' | |
task :up, [:workers] => 'docker-compose.yml' do |_task, args| | |
`docker-compose up -d --scale worker=#{args[:workers]}` unless up? | |
end | |
desc 'Shut down the Citus cluster' | |
task :down => 'docker-compose.yml' do | |
`docker-compose down -v` if up? | |
end | |
desc 'List the running containers' | |
task :status => 'docker-compose.yml' do | |
exec *%w(docker-compose ps) | |
end | |
desc 'Connect to the Citus cluster' | |
task :psql => :up do | |
exec *%W(docker exec -it #{ENV['COMPOSE_PROJECT_NAME']}_master psql -U postgres) | |
end | |
def up? | |
!`docker-compose ps -q`.empty? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place this
Rakefile
into a new directory, and then userake citus:psql
to spin up the cluster and connect to it. The commandrake citus:down
will shut it down when you’re finished.You can specify the number of workers by passing it as the first argument, e.g.
rake citus:up[3]
will start three workers.Based on the commands given in the official Citus Docker guide.