Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
parallelize rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Jul 5, 2020
1 parent fca3afa commit f51bc75
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/bitte/cli/deploy.cr
Expand Up @@ -74,10 +74,24 @@ module Bitte
end

def rebuild
ch = Channel(Nil).new

cluster.nodes.each do |name, node|
sh! "nixos-rebuild",
"--flake", "#{flake}##{cluster_name}-#{name}",
"switch", "--target-host", "root@#{node.public_ip}"
spawn do
begin
sh! "nixos-rebuild",
"--flake", "#{flake}##{cluster_name}-#{name}",
"switch", "--target-host", "root@#{node.public_ip}"
rescue ex
log.error(exception: ex) { "nixos-rebuild failed"}
ensure
ch.send nil
end
end
end

cluster.nodes.each do |_, _|
ch.receive
end
end

Expand Down

0 comments on commit f51bc75

Please sign in to comment.