Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing the server array when using multiple servers #226

Closed
ultrono opened this issue Mar 28, 2021 · 2 comments
Closed

Accessing the server array when using multiple servers #226

ultrono opened this issue Mar 28, 2021 · 2 comments

Comments

@ultrono
Copy link

ultrono commented Mar 28, 2021

I have a simple Envoy file as below (all working and displaying the correct output for each server):

@servers(['.se' => 'ee-se', '.co.uk' => 'ee-couk'])

@story('deploy')
pwd
@endstory

@task('pwd')
cd ~ && pwd;
@endtask

Is it possible to get the current server within a task i.e. if the script is currently deploying on the ".se" server I could access the ".se" or "ee-se"?

Thanks

@driesvints
Copy link
Member

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

@rluetke
Copy link

rluetke commented Sep 27, 2021

I found out, that I can use $__container->getServer($name) to access a server in the TaskContainer https://github.com/laravel/envoy/blob/2.x/src/TaskContainer.php

Another trick is to

  • put the @setup section before the @servers section
  • define a variable for your server in the @setup section
  • use this variable in the @servers section and in any task you like

Example:

@setup
  $server = 'myuser@mydomain.com';
@endsetup

@servers(['localhost' => '127.0.0.1', 'web' => $server])

But remember that a task may be executed on multiple servers and these ideas will not help you finding the actual server.

Regards, Ralf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants