cluster/lib/cluster/runner.rb in sct-1.4.0 vs cluster/lib/cluster/runner.rb in sct-1.5.0
- old
+ new
@@ -1,75 +1,68 @@
module Cluster
class Runner
+ @@dc = system("docker compose version", out: "/dev/null", err: "/dev/null") ? "docker compose" : "docker-compose"
+
def run command, options = {}
begin
if !system command, options
raise command.red
end
rescue Interrupt
# user pressed Ctrl+C, do nothing
end
end
- def dc_system
- return executer = system("which docker-compose") ? 'docker-compose' : 'docker compose'
+ def dc command, options = {}
+ run "#{@@dc} -f ~/development/spend-cloud/docker-compose.yml #{command}", options
end
- def run_dc command, options = {}
- run "#{dc_system} -f ~/development/spend-cloud/docker-compose.yml #{command}", options
- end
-
def start args, options
- print "DC_SYSTEM: #{dc_system}"
if options.pull
- run_dc "pull"
+ dc "pull"
end
if options.build
- run_dc "build #{options.pull ? "--pull" : ""}"
+ dc "build #{options.pull ? "--pull" : ""}"
end
run "docker container prune -f"
- run_dc "up --detach --remove-orphans --force-recreate --always-recreate-deps"
+ 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"
+ dc "down --remove-orphans"
end
- def restart
- run_dc "restart"
- end
-
def delete
- run_dc "down --remove-orphans -v"
+ dc "down --remove-orphans -v"
end
def reset args, options
delete
start args, options
end
def status
- run_dc "ps"
+ 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 " "}"
+ dc "#{command} #{args.join " "}"
end
end
end