Last active
September 22, 2016 18:21
-
-
Save anth-3/cb95668ebe78ddcc50e36d06c1fd6479 to your computer and use it in GitHub Desktop.
Bash/AppleScript to automatically start multiple micro services on Mac OSX using iTerm2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# The local ports the micro services will run on | |
PORT_EMAIL=8080 | |
PORT_ORDERS=8081 | |
PORT_INVENTORY=8082 | |
PORT_PDF=8083 | |
# Main src directory | |
DIR_SRC="$HOME/Source/PHP/Projects/" | |
# The directories for each of the micro services under the main src directory | |
DIR_EMAIL="dtn-email" | |
DIR_ORDERS="dtn-orders" | |
DIR_INVENTORY="dtn-inventory" | |
DIR_PDF="dtn-pdf" | |
echo "Booting DTN Micro Services...." | |
# AppleScript | |
osascript <<EOD | |
tell application "iTerm2" | |
tell current window | |
# Create the first tab | |
create tab with default profile | |
end tell | |
tell current session of current window | |
# Create the second tab | |
split vertically with default profile | |
# Create the third tab | |
split vertically with default profile | |
# Create the fourth tab | |
split vertically with default profile | |
end tell | |
tell first session of current tab of current window | |
set name to "dtn-email" | |
set foreground color to ANSI magenta color | |
set background color to ANSI black color | |
write text "cd $DIR_SRC$DIR_EMAIL/public" | |
write text "pwd" | |
write text "php -S localhost:$PORT_EMAIL" | |
end tell | |
tell second session of current tab of current window | |
set name to "dtn-orders" | |
set foreground color to ANSI bright green color | |
set background color to ANSI black color | |
write text "cd $DIR_SRC$DIR_ORDERS/public" | |
write text "pwd" | |
write text "php -S localhost:$PORT_ORDERS" | |
end tell | |
tell third session of current tab of current window | |
set name to "dtn-inventory" | |
set foreground color to ANSI bright yellow color | |
set background color to ANSI black color | |
write text "cd $DIR_SRC$DIR_INVENTORY/public" | |
write text "pwd" | |
write text "php -S localhost:$PORT_INVENTORY" | |
end tell | |
tell fourth session of current tab of current window | |
set name to "dtn-pdf" | |
set foreground color to ANSI cyan color | |
set background color to ANSI black color | |
write text "cd $DIR_SRC$DIR_PDF/public" | |
write text "pwd" | |
write text "php -S localhost:$PORT_PDF" | |
end tell | |
end tell | |
EOD | |
echo "...Micro Services started successfully" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment