deployphp / deployer

The PHP deployment tool with support for popular frameworks out of the box
https://deployer.org
MIT License
10.41k stars 1.47k forks source link

Deploy all hosts asynchronously rather than synchronously #3827

Open sts-ryan-holton opened 1 month ago

sts-ryan-holton commented 1 month ago

I'm using the latest version of Deployer to deploy my Nuxt JS project to multiple ipv6 hosts. If I were to deploy one host individually, it wouldn't take no more than 5 minutes. But when defining multiple hosts, it seems that it deploys synchronously through each one, I'd like to be able to configure it to deploy to all at the same time because it takes over an hour right now, additionally, if something fails, then deployments to all hosts fail and are locked which is quite frustrating.

What are your thoughts?

This is my deployment hosts:

host('a420:c3d3:ba97:c042:deff:8a15:fbfd:6276', 'c7b3:ea23:e29f:2564:8187:13aa:d2f3:bf36', 'ae7c:af20:e51d:1449:cc45:7e07:644f:33ba')
    ->set('branch', 'main')
    ->stage('all')
    ->set('repository', 'git@fudge:company/project)
    ->user('root')
    ->set('deploy_path', '/var/www/include-forms/fudge');

And I deploy running:

dep deploy all

Upvote & Fund

Fund with Polar

Schrank commented 1 month ago

From the doc:

Deployer runs a task in parallel on each host. This is why the output is mixed. We can limit it to run only on one host at a time.

This should be the default. Are you saying this doesn’t work for you?

can you check -vvv?

sts-ryan-holton commented 1 month ago

It seems to take a long time. 41 minutes to deploy to around 20 - 25 hosts

Schrank commented 1 month ago

Please try

dep deploy all -vvv

then you see wether it works parallel or not.

antonmedv commented 1 month ago

additionally, if something fails, then deployments to all hosts fail and are locked

This is a feature of Deployer ʕっ•ᴥ•ʔっ

Deployer tried to keep all deployment hosts in sync (as Deployer does not know if it is save to deploy only to one host and allow other to fail).

This feature was requested a few times and I think it will be nice to add a simple API to configure deploy to run deploys not in sync.

Right now you can do:

dep deploy host1 &
dep deploy host2 &
dep deploy host3 &
sts-ryan-holton commented 1 month ago

How do I know if parallel deploying is working with that flag?

sts-ryan-holton commented 3 weeks ago

@antonmedv It was working. Turned out I was looking at the wrong deployer version. Additionally though, linked to a newer Github issue. How can I deploy to one server in parallel model across many alias folders here:

$sites = ['site1', 'site2'];

// Site: Fudge
foreach ($sites as $site) {
    host("ipv6/$site")
        ->set('labels', ['stage' => 'forms', 'site' => $site])
        ->set('repository', 'git@application-fudge:company/application-fudge')
        ->set('branch', 'feature/fudge_v2')
        ->set('remote_user', 'root')
        ->set('deploy_path', "/var/www/forms/fudge/$site");
}