Scripts to do something on multiple applications
Table of Contents
How to start multiple applications from terminal
In Windows machines
See https://ss64.com/nt/for_f.html
Prerequisite: ConEmu
for /f "tokens=5" %%a in ('netstat -aon ^| find ":8001" ^| find "LISTENING" ') do taskkill /f /pid %%a
for /f "tokens=5" %%a in ('netstat -aon ^| find ":8002" ^| find "LISTENING" ') do taskkill /f /pid %%a
for /f "tokens=5" %%a in ('netstat -aon ^| find ":8003" ^| find "LISTENING" ') do taskkill /f /pid %%a
for /f "tokens=5" %%a in ('netstat -aon ^| find ":8004" ^| find "LISTENING" ') do taskkill /f /pid %%a
for /f "tokens=5" %%a in ('netstat -aon ^| find ":8005" ^| find "LISTENING" ') do taskkill /f /pid %%a
cd C:\Users\<username>\Downloads\GitRepositories\application1
start mvn spring-boot:run -new_console:t:"application1"
cd..
timeout 20
cd C:\Users\<username>\Downloads\GitRepositories\application2
start mvn spring-boot:run -new_console:t:"application2"
cd..
timeout 20
cd C:\Users\<username>\Downloads\GitRepositories\application3
start mvn spring-boot:run -new_console:t:"application3"
cd..
timeout 20
cd C:\Users\<username>\Downloads\GitRepositories\application4
start mvn spring-boot:run -new_console:t:"application4"
cd..
timeout 20
k
cd C:\Users\<username>\Downloads\GitRepositories\application5
start mvn spring-boot:run -new_console:t:"application5"
cd..
timeout 20
(If you want to allow a time delay to make sure that all the applications start successfully)
timeout 100
netstat -a -n | findstr :8001
netstat -a -n | findstr :8002
netstat -a -n | findstr :8003
netstat -a -n | findstr :8004
netstat -a -n | findstr :8005
In *nix machines
#!/bin/bash
# Prerequisites: tmux
# How to run:
# From terminal (iterm2 provides better scrolling options compared to MacBook's default terminal), run this script:sh Downloads/StartLocalApplications.sh
# tmux ls (to list all the tmux sessions)
# tmux attach -t ListOfAppsToBeStarted (to attach to the session ListOfAppsToBeStarted)
# Ctrl-b w to select the window to jump to.
# You can use tmux kill-server to cleanly and gracefully kill all tmux open sessions (and server).
session="ListOfAppsToBeStarted"
tmux new-session -d -s $session
window=0
tmux rename-window -t $session:$window 'my-app-1'
tmux send-keys -t $session:$window 'cd ~/Downloads/GitRepositories/my-app-1' C-m
tmux send-keys -t $session:$window 'nvm use' C-m
tmux send-keys -t $session:$window 'yarn start:local' C-m
window=1
tmux new-window -t $session:$window -n 'my-app-2'
tmux send-keys -t $session:$window 'cd ~/Downloads/GitRepositories/my-app-2' C-m
tmux send-keys -t $session:$window 'nvm use' C-m
tmux send-keys -t $session:$window 'yarn start:local' C-m
window=2
tmux new-window -t $session:$window -n 'my-app-3'
tmux send-keys -t $session:$window 'cd ~/Downloads/GitRepositories/my-app-3' C-m
tmux send-keys -t $session:$window 'nvm use' C-m
tmux send-keys -t $session:$window 'yarn start:local' C-m
window=3
tmux new-window -t $session:$window -n 'my-app-4'
tmux send-keys -t $session:$window 'cd ~/Downloads/GitRepositories/my-app-4' C-m
tmux send-keys -t $session:$window 'nvm use' C-m
tmux send-keys -t $session:$window 'yarn start:local' C-m
window=4
tmux new-window -t $session:$window -n 'my-app-5'
tmux send-keys -t $session:$window 'cd ~/Downloads/GitRepositories/my-app-5' C-m
tmux send-keys -t $session:$window 'nvm use' C-m
tmux send-keys -t $session:$window 'yarn start:local' C-m
window=5
tmux new-window -t $session:$window -n 'my-app-6'
tmux send-keys -t $session:$window 'cd ~/Downloads/GitRepositories/my-app-6' C-m
tmux send-keys -t $session:$window 'nvm use' C-m
tmux send-keys -t $session:$window 'yarn start:local' C-m
window=6
tmux new-window -t $session:$window -n 'pagro-reference-api'
tmux send-keys -t $session:$window 'cd ~/Downloads/GitRepositories/my-app-7' C-m
tmux send-keys -t $session:$window 'nvm use' C-m
tmux send-keys -t $session:$window 'yarn start:local' C-m
How to pull latest code using Git in Windows machines
Set this up as a .bat script and run it.
cd C:\temp\GitRepositories/application1
git remote update --prune
git merge remotes/origin/develop
cd C:\temp\GitRepositories/application2
git remote update --prune
git merge remotes/origin/develop
cd C:\temp\GitRepositories/application3
git remote update --prune
git merge remotes/origin/develop
....