require 'hsm/config' require 'rake' module Hsm class Tasks < Rake::TaskLib # Defaults to config/hsm.rb attr_accessor :hsm_config_path # Allow Rakefiles to define local variables def initialize @hsm_config_path = 'config/hsm.rb' yield self if block_given? define_tasks end # Load up the configuration, and generate tasks for each machine and service # defined. def define_tasks config.machines.each do |machine_name, machine_conf| desc "Print status of machine #{machine_name}" task "hsm:#{machine_name}:status" do sh "docker-machine ls #{machine_name}" end task "hsm:#{machine_name}:ps" do sh "$(docker-machine env #{machine_name}) && docker ps" end config.services.each do |service_name, service| desc "Print status of service #{service_name}" task "hsm:#{machine_name}:#{service_name}:status" do sh "$(docker-machine env #{machine_name}) && cd #{service[:path]} && docker-compose ps" end desc "Stop service #{service_name}" task "hsm:#{machine_name}:#{service_name}:stop" do sh "$(docker-machine env #{machine_name}) && cd #{service[:path]} && docker-compose stop" end desc "Start service #{service_name}" task "hsm:#{machine_name}:#{service_name}:start" do sh "$(docker-machine env #{machine_name}) && cd #{service[:path]} && docker-compose start" end desc "Up (create and start) service #{service_name}" task "hsm:#{machine_name}:#{service_name}:up" do sh "$(docker-machine env #{machine_name}) && cd #{service[:path]} && docker-compose up -d" end desc "Build service #{service_name}" task "hsm:#{machine_name}:#{service_name}:build" do sh "$(docker-machine env #{machine_name}) && cd #{service[:path]} && docker-compose build --no-cache" end desc "Remove service #{service_name}" task "hsm:#{machine_name}:#{service_name}:rm" do sh "$(docker-machine env #{machine_name}) && cd #{service[:path]} && docker-compose rm --force" end desc "Reset (rm and up) service #{service_name}" task "hsm:#{machine_name}:#{service_name}:reset" => %W( hsm:#{machine_name}:#{service_name}:stop hsm:#{machine_name}:#{service_name}:rm hsm:#{machine_name}:#{service_name}:build hsm:#{machine_name}:#{service_name}:up ) desc "Republish gem (build, up, and rm) service #{service_name}" task "hsm:#{machine_name}:#{service_name}:gem" => %W( hsm:#{machine_name}:#{service_name}:build hsm:#{machine_name}:#{service_name}:up hsm:#{machine_name}:#{service_name}:rm ) end end end def config @config ||= init_config end private def init_config config_str = IO.read(@hsm_config_path, mode: 'r') @config = Config.new @config.instance_eval(config_str) @config end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 13528 | tjuricek |
Moved rack and app server configuration to be managed via Salt. Also, only using a single value "url" to configure how the p4_project_services instance references the p4_web_api. And, removing the Docker setup, since that won't work for a production system. |
||
#2 | 13488 | tjuricek |
Added hsm:startworld and hsm:stopworld tasks to do global starts and stops. This is not without apparent issues. It appears bundler or ruby is pausing before the nginx launch task happens. I'm not sure if there's some kind of resource issue first. P4WEBAPI-49 |
||
#1 | 13480 | tjuricek |
Creating several Rake tasks for our "hsm" configuration that are based on a Ruby API config file. The config file points to machines and services in the system which then takes care of setting up the docker-machine environment and docker-compose configuration. |