Comments (6)
@robd Please hold off on this one for now, as I think some more discussion is needed. I am worried that this changes what I consider desirable behavior for multi-server deployments, where the same command running on multiple servers share the same number prefix.
When e.g. running echo foo
on three servers, I think I prefer this:
01 echo foo
✔ 01 user@server1 0.004s
✔ 01 user@server2 0.004s
✔ 01 user@server3 0.004s
Rather than:
01 echo foo
✔ 01 user@server1 0.004s
02 echo foo
✔ 02 user@server2 0.004s
03 echo foo
✔ 03 user@server3 0.004s
In my mind, it is one command, three executions rather than three separate commands (even though it really is three distinct command UUIDs behind the scenes). That is why airbrussh currently compares commands using to_s
rather than UUID.
That said, I agree that if you did run the same command three times in a row on one server, that the output is not ideal. However I consider that a fairly uncommon scenario. Right now to_s
is kind of a blunt instrument that doesn't allow us to distinguish duplicate commands from multi-server executions of the same command.
from airbrussh.
Ah OK I see - that makes sense, and I agree
I guess I am just unfortunate in that I happen to see this during my deployments:
01:05 nginx:install
Downloading nginx.conf.erb 100.0%
Uploading /tmp/tmp.conf 100.0%
01 sudo install -m 0600 /tmp/tmp.conf /etc/nginx/nginx.conf
✔ 01 [email protected] 0.289s
02 sudo rm /tmp/tmp.conf
✔ 02 [email protected] 0.250s
Downloading mime.types.erb 100.0%
Uploading /tmp/tmp.conf 100.0%
03 sudo install -m 0600 /tmp/tmp.conf /etc/nginx/mime.types
✔ 03 [email protected] 0.144s
✔ 02 [email protected] 0.144s
04 sudo install -m 0600 /var/www/domain/current/config/nginx/ssl/certs/www.domain.co.uk.crt /etc/ssl/certs/www.domain.co.uk.crt
✔ 04 [email protected] 0.172s
05 sudo install -m 0600 /var/www/domain/current/config/nginx/ssl/private/www.domain.co.uk.key /etc/ssl/private/www.domain.co.uk.key
✔ 05 [email protected] 0.155s
Downloading nginx-vhosts.conf.erb 100.0%
Uploading /tmp/tmp.conf 100.0%
06 sudo install -m 0600 /tmp/tmp.conf /etc/nginx/sites-available/domain_staging.conf
✔ 06 [email protected] 0.162s
✔ 02 [email protected] 0.150s
07 sudo rm -f /etc/nginx/sites-enabled/domain_staging.conf
✔ 07 [email protected] 0.150s
08 sudo ln -s /etc/nginx/sites-available/domain_staging.conf /etc/nginx/sites-enabled/domain_staging.conf
✔ 08 [email protected] 0.153s
Downloading nginx.erb 100.0%
Uploading /tmp/tmp.conf 100.0%
09 sudo install -m 0600 /tmp/tmp.conf /etc/logrotate.d/nginx
✔ 09 [email protected] 0.193s
✔ 02 [email protected] 0.158s
Output with #54:
01:08 nginx:install
Downloading nginx.conf.erb 100.0%
Uploading /tmp/tmp.conf 100.0%
01 sudo install -m 0600 /tmp/tmp.conf /etc/nginx/nginx.conf
✔ 01 [email protected] 0.164s
02 sudo rm /tmp/tmp.conf
✔ 02 [email protected] 0.156s
Downloading mime.types.erb 100.0%
Uploading /tmp/tmp.conf 100.0%
03 sudo install -m 0600 /tmp/tmp.conf /etc/nginx/mime.types
✔ 03 [email protected] 0.157s
04 sudo rm /tmp/tmp.conf
✔ 04 [email protected] 0.161s
05 sudo install -m 0600 /var/www/domain/current/config/nginx/ssl/certs/www.domain.co.uk.crt /etc/ssl/certs/www.domain.co.uk.crt
✔ 05 [email protected] 0.165s
06 sudo install -m 0600 /var/www/domain/current/config/nginx/ssl/private/www.domain.co.uk.key /etc/ssl/private/www.domain.co.uk.key
✔ 06 [email protected] 0.160s
Downloading nginx-vhosts.conf.erb 100.0%
Uploading /tmp/tmp.conf 100.0%
07 sudo install -m 0600 /tmp/tmp.conf /etc/nginx/sites-available/domain_staging.conf
✔ 07 [email protected] 0.157s
08 sudo rm /tmp/tmp.conf
✔ 08 [email protected] 0.153s
09 sudo rm -f /etc/nginx/sites-enabled/domain_staging.conf
✔ 09 [email protected] 0.150s
10 sudo ln -s /etc/nginx/sites-available/domain_staging.conf /etc/nginx/sites-enabled/domain_staging.conf
✔ 10 [email protected] 0.139s
Downloading nginx.erb 100.0%
Uploading /tmp/tmp.conf 100.0%
11 sudo install -m 0600 /tmp/tmp.conf /etc/logrotate.d/nginx
✔ 11 [email protected] 0.162s
12 sudo rm /tmp/tmp.conf
✔ 12 [email protected] 0.206s
As you can see, it's quite misleading at the moment. There are 12 commands, not 9 as reported by Airbrussh, and the order of command completions isn't ideal. Obviously I could fix this by using a different temporary filename, but I think it would be better if I didn't have to code round Airbrussh.
I now understand what first_execution
means! This is intended to mean 'is it executing on the first server?' as opposed to 'is this a repeat command?'.
I guess this is non trivial to fix. Do I remember you saying that the command is duplicated for each server? I guess it must be in order to store separate command output etc.
As I see it there are 2 responsibilities needed from the history:
first_execution?(command)
akaexecuted_on_another_server?
position(command)
For me, the ideal fix would be to split the Command
and CommandExecution
objects in SSHKit so that in the formatter you get a CommandExecution
which has a @command
attribute. We would no longer duplicate the Command
and all CommandExecution
s would point to the same Command
so you wouldn't get multiple UUIDs. I think this would make #54 work as intended.
from airbrussh.
I now understand what first_execution means! This is intended to mean 'is it executing on the first server?' as opposed to 'is this a repeat command?'.
Exactly!
For me, the ideal fix would be to split the Command and CommandExecution objects in SSHKit so that in the formatter you get a CommandExecution which has a
@command
attribute.
Yes, that was my thought as well.
Without that change, I don't think there is enough information in the current Command object to distinguish a duplicate command from multi-server execution.
from airbrussh.
Without that change, I don't think there is enough information in the current Command object to distinguish a duplicate command from multi-server execution.
No, I agree. I thought of a couple of workarounds, such as hooking SSHKit / Capistrano to detect if there are multiple hosts, or moving into 'multiple host' matching mode once we spot a different host on a command. But I think it would be cleaner just to fix this in SSHKit.
Just out of interest - do you use Airbrussh on multiple hosts day to day? I never have, so I always forget about this (common) use case.
from airbrussh.
Just out of interest - do you use Airbrussh on multiple hosts day to day? I never have, so I always forget about this (common) use case.
Yes, right now I have two active projects that use multi-server production environments: one with 3 servers (app, db, worker), and one with 2 (app, db).
from airbrussh.
Would ignoring only consecutive executions work as a viable workaround for this? It may not be bullet-proof, but it seems like an improvement on the current implementation?
from airbrussh.
Related Issues (20)
- AppVeyor CI (Windows) builds failing with net-ssh 4.0.0
- command_output HOT 9
- Colors in the capistrano.log file HOT 3
- Circular dependency warning
- Empty console output HOT 9
- Customize output to show server hostname HOT 1
- Mocha::NotInitializedError on stubbed tests when running minitest locally HOT 2
- "invalid byte sequence in UTF-8" when rsyncing files with international character
- Make rake a gem dependency HOT 3
- Make ConsoleFormatter's context configurable HOT 5
- Console error only when using Spring HOT 1
- Test on ruby 3
- Travis-CI builds are no longer working HOT 3
- Replace Travis with CircleCI HOT 1
- Switch from alias_method to prepend HOT 7
- Colorize LogMessages again HOT 3
- IO.console can be nil
- Vague and unhelpful error message if log cannot be created HOT 4
- Hostname in output HOT 1
- Tests fail under Ruby 2.4.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from airbrussh.