Sha256: 211a3747ce2b8a29c80b3ea26917aff1d47ef446f7191ea7cf31289b44dff002

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

module Cluster
  class Runner

    def run command, options = {}
      begin
        if !system command, options
          raise command.red
        end
      rescue Interrupt
        # user pressed Ctrl+C, do nothing
      end
    end

    def run_dc command, options = {}
      run "docker-compose -f ~/development/spend-cloud/docker-compose.yml #{command}", options
    end

    def start args, options
      if options.pull
        run_dc "pull"
      end

      if options.build
        run_dc "build #{options.pull ? "--pull" : ""}"
      end

      run "docker container prune -f"

      run_dc "up --detach --remove-orphans --force-recreate --always-recreate-deps"

      if options.pull or options.build
        system "docker image prune -f"
      end

      UI.success("\nāœ”ļø You can visit your environment at šŸ‘‰ https://spend-cloud.dev.spend.cloud šŸ‘Œ")
    end

    def stop
      run_dc "down --remove-orphans"
    end

    def restart
      run_dc "restart"
    end

    def delete
      run_dc "down --remove-orphans -v"
    end

    def reset args, options
      delete
      start args, options
    end

    def status
      run_dc "ps"
    end

    def logs args, options
      command = "logs"

      command << " --follow" if options.f or options.follow
      command << " --timestamps" if options.t or options.timestamps
      command << " --tail #{options.tail}" if options.tail

      run_dc "#{command} #{args.join " "}"
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sct-1.3.0 cluster/lib/cluster/runner.rb
sct-1.2.0 cluster/lib/cluster/runner.rb