tmuxinator only runs commands of first pane correctly - tmux

I have a .tmuxinator.yml which looks like this:
pre_window:
windows:
- workspace:
layout: even-vertical
panes:
- health:
- printf '\033]2;%s\033\\' 'healthcheck'
- cd dev-env
- clear
- work:
- printf '\033]2;%s\033\\' 'workspace'
- clear
- api:
layout: even-vertical
panes:
- database:
- printf '\033]2;%s\033\\' 'api-database'
- cd api
- docker-compose up
- server:
- printf '\033]2;%s\033\\' 'api'
- cd api
- yarn watch
- workspace:
- printf '\033]2;%s\033\\' 'api-workspace'
- cd api
- clear
This used to work but now it only runs the first pane commands correctly which means it just doesn't call the commands after the printf ... statements for any other than the first one in each window.
Update: removing the `printf ...' statements seems to fix it but I would like to keep them.
I'm using
tmux 3.2a
tmuxinator 3.0.1
macOS 12.0.1 (Monterey - the problem is not caused by Monterey as the problem did exist before)
I've double checked the line endings using cat -e .tmuxinator.yml.

Related

How to enable linting in r package in gitlab ci/cd pipeline

I have created CI pipeline in gitlab for r-package. I need to capture the lint output and fails the job if there is any lint error. I'm unable to read the output of lintr command.
image: r-base:4.1.2
stages:
- LintR
LintR:
stage: LintR
script:
- cd ..
- R -e "capture.output(lintr::lint_package(\"./test-r/\"), file=\"./lint_output.txt\")"
- cd isp-r && mv ../lint_output.txt .
artifacts:
paths:
- ./lint_output.txt
when: always
How to capture the output in gitlab CI/CD
Try the following:
image: r-base:4.1.2
stages:
- LintR
LintR:
stage: LintR
script:
# redirect lintr stdout and stderr to file
- CI="" R -e "lintr::lint_package()" &> lint_output.txt
# fail if file is not empty
- [ ! -s lint_output.txt ]
artifacts:
paths:
- lint_output.txt

Corda standalone shell - execute command without entering into shell

The --help of Cords Standalone Shell says the following:
corda-shell [-hvV] [--logging-level=<loggingLevel>] [--password=<password>]
[--sshd-hostkey-directory=<sshdHostKeyDirectory>]
[--sshd-port=<sshdPort>] [--truststore-file=<trustStoreFile>]
[--truststore-password=<trustStorePassword>]
[--truststore-type=<trustStoreType>] [--user=<user>] [-a=<host>]
[-c=<cordappDirectory>] [-f=<configFile>] [-o=<commandsDirectory>]
[-p=<port>] [COMMAND]
Now I was thinking that after specifying the appropriate parameters I can specify the [COMMAND] which I want to be executed on the node (e.g. run gracefulShutdown) but I cannot find a way to do that with standalone shell. Is there a way to do that or may be I am on wrong direction?
P.S. I need to drain and shut down the node before deploying the new cordapp in my CI/CD flow, thats why I need run gracefulShutdown.
When I try to run a command using this technique I get the following error:
Unmatched argument: help
Did you mean: install-shell-extensions?
Method-1 -- Submit/STDIN the commands via pipe.
echo -e "run nodeInfo\nexit"|java -jar corda-tools-shell-cli-4.8.7.jar \
--truststore-file /$PWD/certificates/export/rpcssltruststore.jks \
--truststore-password=apple -p=10006 -a localhost \
--user user1 --password=test
Method-2 -- Text the commands in a file and provide it as STDIN
]$ cat /tmp/commands
run nodeInfo
exit
]$ java -jar ~/bin/es/corda-tools-shell-cli-4.8.7.jar --truststore-file /$PWD/certificates/export/rpcssltruststore.jks --truststore-password=rpctruststorepassword -p=10006 -a localhost --user user1 --password=test < /tmp/commands
______ __
/ ____/ _________/ /___ _
/ / __ / ___/ __ / __ `/
/ /___ /_/ / / / /_/ / /_/ /
\____/ /_/ \__,_/\__,_/
--- Corda Enterprise Edition 4.8.7 (8baf4b1) ---
Standalone Shell connected to localhost:10006
Welcome to the Corda interactive shell.
Useful commands include 'help' to see what is available, and 'bye' to exit the shell.
Tue Jul 26 16:01:16 SGT 2022>>> run nodeInfo
addresses:
- "localhost:10005"
legalIdentitiesAndCerts:
- "O=PartyA, L=London, C=GB"
platformVersion: 10
serial: 1658810279418
Tue Jul 26 16:01:16 SGT 2022>>> exit
Have a good day!
]$
Important is to ensure and keep exit at the end.
You need to first enter into the shell to be able to issue commands to the node. The [COMMAND] parameter is probably a little misleading, The only command it has is 'install-shell-extension' which just adds an alias so that the jar can be run using a suitable name like 'corda-shell'.

How to set pane titles with tmuxinator

How do you set a unique title on each pane in a tmuxinator session?
I'm trying to run multiple panes to show the output from htop being run through ssh to different servers. My configuration looks like:
project_name: Server Monitor
windows:
- servers:
layout: tiled
panes:
- ssh -t -i mykey.pem user#server1 htop
- ssh -t -i mykey.pem user#server2 htop
- ssh -t -i mykey.pem user#server3 htop
When I launch this with tmuxinator local, it runs the commands just fine and I see the output from htop. However, the panes all look the same and the SSH title isn't shown, making it nearly impossible to tell which pane corresponds to which server.
How do I change my configuration so that a unique title is shown on each pane?
This example shows that this feature is supported in the underlying tmux, but I'm not sure how to access this through tmuxinator.
What you need to do is first enable pane status in your .tmux.conf with the lines:
set -g pane-border-format "#{pane_index} #{pane_title}"
set -g pane-border-status bottom
Then add to your tmuxinator config a printf command that will send the appropriate escape sequence to dynamically set the pane title. You will have 2 commands now per pane, so you need to add another level of indentation with a name.
project_name: Server Monitor
windows:
- servers:
layout: tiled
panes:
- p1:
- printf '\033]2;%s\033\\' 'server1'
- ssh -t -i mykey.pem user#server1 htop
- p2:
- printf '\033]2;%s\033\\' 'server2'
- ssh -t -i mykey.pem user#server2 htop
- p3:
- printf '\033]2;%s\033\\' 'server3'
- ssh -t -i mykey.pem user#server3 htop
You need at least tmux 2.3 to have pane titles shown in the borders.
For anyone else who comes across this and:
Doesn't want to change their layout
Has a problem parsing the structure in Meuh's answer (I was getting a undefined method shellescape for #<Array error.
You still need to add these to your .tmux.conf:
set -g pane-border-format "#{pane_index} #{pane_title}"
set -g pane-border-status bottom
You can just add a ; before the ssh command and do this:
name: myBoxes
root: ~/
windows:
- hosts:
layout: tiled
panes:
- printf '\033]2;%s\033\\' 'role_storage_v45 : hostname2.net'; ssh 10.20.30.1
- printf '\033]2;%s\033\\' 'role_dns_v15 : hostname1.net'; ssh 10.20.30.2

multiple panes with tmuxinator

I' trying to build a tmuxinator with multiple windows and in one of them i`d like to build 2 panes:
name: bigbang-server
root: ~/projects/bigbang
windows:
- CORE:
- ...
- CONSOLE:
- ...
- FUND_TRANSACTIONS:
- ...
- CLIENT_POSITIONS:
pre_window: cd ~/projects/bigbang_services/
panes:
server:
- env PORT=3002 rails server
sidekiq:
- bundle exec sidekiq -C config/sidekiq.yml
it doesnt run any of my last window commands, here its debug:
# Window "CLIENT_POSITIONS"
tmux select-window -t 1
tmux select-pane -t 0
if [ -z "$TMUX" ]; then
tmux -u attach-session -t bigbang-server
else
tmux -u switch-client -t bigbang-server
fi
It seems there are some points to fix.
pre_window: should be top-level, not under windows:.
Any hash element (like name:) is not allowed under the pane:.
Like this.
name: bigbang-server
root: ~/projects/bigbang
pre_window: cd ~/projects/bigbang_services/
windows:
- CORE:
- ...
- CONSOLE:
- ...
- FUND_TRANSACTIONS:
- ...
- CLIENT_POSITIONS:
panes:
- env PORT=3002 rails server
- bundle exec sidekiq -C config/sidekiq.yml
The way you wrote the commands for the panes in that particular window is wrong.
It should have been something like this:
windows:
- CLIENT_POSTIONS:
panes:
- cd ~/projects/bigbang_services/
- env PORT=3002 rails server
- bundle exec sidekiq -C config/sidekiq.yml
This creates 2 horizontal splits first then splits the first one vertically.
To use horizontal or vertical splits throughout the window,
use main-horizontal or main-vertical.
Like this:
windows:
- CLIENT_POSTIONS:
layout: main-vertical # or main-horizontal
panes:
- cd ~/projects/bigbang_services/
- env PORT=3002 rails server
- bundle exec sidekiq -C config/sidekiq.yml

How can I execute multiple commands using Salt Stack?

I tried to add:
mypack:
pkg:
- installed
- pkgs:
- mercurial
- git
cmd.run:
- name: 'mkdir -p /opt/mypack'
cmd.run: 'hg pull -u -R /opt/mypack || hg clone -R /opt https://...'
cmd.run: 'ln -s /opt/mypack/etc/init.d/xxx /etc/init.d/xxx'
But for some reason this the state seems to execute/install but the commands are not executed, or at least not all of them.
I need a solution to run multiple commands and to fail the deployment if any of these fails.
I know that I could write a bash script and include this bash script, but I was looking for a solution that would work with only the YAML file.
You want this:
cmd-test:
cmd.run:
- name: |
mkdir /tmp/foo
chown dan /tmp/foo
chgrp www-data /tmp/foo
chmod 2751 /tmp/foo
touch /tmp/foo/bar
Or this, which I would prefer, where the script is downloaded from the master:
cmd-test:
cmd.script:
- source: salt://foo/bar.sh
- cwd: /where/to/run
- user: fred
In addition to the above (better) suggestions, you can do this:
cmd-test:
cmd.run:
- names:
- mkdir -p /opt/mypack
- hg pull -u -R /opt/mypack || hg clone -R /opt https://...
- ln -s /opt/mypack/etc/init.d/xxx /etc/init.d/xxx
For reasons I don't understand yet (I'm a Salt novice), the names are iterated in reverse order, so the commands are executed backwards.
You can do as Dan pointed out, using the pipe or a cmd.script state. But it should be noted that you have some syntax problems in your original post. Each new state needs a name arg, you can't just put the command after the colon:
mypack:
pkg:
- installed
- pkgs:
- mercurial
- git
cmd.run:
- name: 'my first command'
cmd.run:
- name: 'my second command'
However, that actually may fail as well, because I don't think you can put multiple of the same state underneath a single ID. So you may have to split them out like this:
first:
cmd.run:
- name: 'my first command'
second:
cmd.run:
- name: 'my second command'
As one of the users pointed out above, this works in proper order (salt 3000.2)
install_borg:
cmd.run:
- names:
- cd /tmp
- wget https://github.com/borgbackup/borg/releases/download/1.1.15/borg-linux64
- mv borg-linux64 /usr/local/bin/borg
- chmod u+x /usr/local/bin/borg
- chown root:root /usr/local/bin/borg
- ln -s /usr/local/bin/borg /usr/bin/borg
- unless: test -f /usr/bin/borg

Resources