-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: start local env #67
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,69 @@ | ||||||
#!/bin/sh | ||||||
|
||||||
# remember to chmod +x start_local_env.sh | ||||||
kotorekisteri_start_tmux() { | ||||||
SESS_NAME=kotorekisteri | ||||||
PANE1=kotorekisteri | ||||||
REPO_ROOT=${1:-'.'} | ||||||
|
||||||
( | ||||||
cd $REPO_ROOT | ||||||
|
||||||
# Install dependencies | ||||||
echo "Installing dependencies..." | ||||||
mise install | ||||||
|
||||||
# Use old session if exists | ||||||
tmux has-session -t $SESS_NAME 2>/dev/null | ||||||
if [ $? -eq 0 ]; then | ||||||
tmux attach -t $SESS_NAME | ||||||
# TODO: Instead of return, kill the old session. | ||||||
return | ||||||
fi | ||||||
|
||||||
# If there is no session... | ||||||
# Start a new tmux session and detach immediately | ||||||
# Window 0:zsh | ||||||
echo "Starting new tmux session..." | ||||||
tmux new-session -d -s $SESS_NAME | ||||||
|
||||||
# Window 0:database | ||||||
WINDOW="database" | ||||||
# database: left pane (docker running) | ||||||
tmux rename-window -t $SESS_NAME:0 "$WINDOW" | ||||||
tmux send-keys -t $SESS_NAME:"$WINDOW.0" "open -a \"Docker\"" C-m | ||||||
tmux send-keys -t $SESS_NAME:"$WINDOW.0" "docker compose up" C-m | ||||||
|
||||||
# database: right pane (flyway migrate) | ||||||
tmux split-window -h -t $SESSION:"$WINDOW" | ||||||
tmux send-keys -t $SESS_NAME:"$WINDOW.1" "(cd server && | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tää on vähä ruma stdoutissa, mutta hoitaa asiansa, eli ajaa migraatiot sitten kun docker on pystyssä. |
||||||
sleep 5 && echo \"10 seconds left to run migrations...\" && | ||||||
sleep 5 && echo \"05 seconds left to run migrations...\" && | ||||||
./mvnw flyway:migrate)" C-m | ||||||
|
||||||
# Window 1:idea | ||||||
WINDOW="idea" | ||||||
tmux new-window -t $SESS_NAME -n "idea" | ||||||
tmux send-keys -t $SESS_NAME:"idea" "idea ." C-m | ||||||
|
||||||
# Window 2:springboot | ||||||
WINDOW="springboot" | ||||||
tmux new-window -t $SESS_NAME -n "$WINDOW" | ||||||
tmux send-keys -t $SESS_NAME:"$WINDOW" "cd server && sleep 5" C-m | ||||||
tmux send-keys -t $SESS_NAME:"$WINDOW" "mvn clean install" C-m | ||||||
tmux send-keys -t $SESS_NAME:"$WINDOW" "mvn package" C-m | ||||||
tmux send-keys -t $SESS_NAME:"$WINDOW" "./mvnw spring-boot:run" C-m | ||||||
|
||||||
# Window 3:workspace | ||||||
WINDOW="workspace" | ||||||
tmux new-window -t $SESS_NAME -n "$WINDOW" | ||||||
tmux send-keys -t $SESS_NAME:"$WINDOW" "git log --oneline --decorate=full --graph --all --oneline" C-m | ||||||
tmux split-window -h -t $SESSION:"$WINDOW" | ||||||
tmux send-keys -t $SESS_NAME:"$WINDOW.1" "ls -la" C-m | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
tmux send-keys -t $SESS_NAME:"$WINDOW.1" "git status" C-m | ||||||
|
||||||
tmux attach | ||||||
) | ||||||
} | ||||||
|
||||||
kotorekisteri_start_tmux $1 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Näin se poistais vanhan session, jos haluais, että scripti luo kaiken aina alusta.