Sha256: 242654ff1e6fa001f6b0e9709fe70d2bd97699223d18debad5674aa06f85ff83

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 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"

      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

9 entries across 9 versions & 1 rubygems

Version Path
sct-1.1.2 cluster/lib/cluster/runner.rb
sct-1.1.1 cluster/lib/cluster/runner.rb
sct-1.1.0 cluster/lib/cluster/runner.rb
sct-1.0.9 cluster/lib/cluster/runner.rb
sct-1.0.8 cluster/lib/cluster/runner.rb
sct-1.0.7 cluster/lib/cluster/runner.rb
sct-1.0.6 cluster/lib/cluster/runner.rb
sct-1.0.5 cluster/lib/cluster/runner.rb
sct-1.0.4 cluster/lib/cluster/runner.rb