Skip to content

Instantly share code, notes, and snippets.

@tylerhunt
Last active December 7, 2017 21:07
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 tylerhunt/657dc9c31644c0d0a8048945f36f7433 to your computer and use it in GitHub Desktop.
Save tylerhunt/657dc9c31644c0d0a8048945f36f7433 to your computer and use it in GitHub Desktop.
A Rakefile for trying out Citus using Docker
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
@tylerhunt
Copy link
Author

tylerhunt commented Dec 7, 2017

Place this Rakefile into a new directory, and then use rake citus:psql to spin up the cluster and connect to it. The command rake 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment