ematrixsys 2.0 - tmux startup script

ematrix | ematrixsys | TMUX STARTUP

When rebooting the mac mini in Wels we need to bring up “public” dev-mode instances.

To do so, we start TMUX-Sessions and run the iex -S mix phx.server inside each session.

The script is located at

local/tmux-startup-development/start_development.sh

and is version controlled at Github

Running Instances

Find the documentation about running instances at docs.ematrixsys.com

The script start_development.sh

#!/usr/bin/env bash

echo "Start up development services in TMUX"
echo "====================================="

export TMUX_SESSION_RUNNING=1

WORKDIRS="$HOME/src/demo $HOME/src/demo-visitor $HOME/src/anna $HOME/src/eec-demo-ebner $HOME/src/eec $HOME/src/production-copies/eec/demo-3eag"

# SERVICES

# /Users/developer/src/local/postgresql
#   should start up from the docker-compose file if it was up before the reboot.
#
#

function setup_workdir {
  echo "Setup $1"
  PREFIX=$(pwd)
  SESSION=$(basename $1)
  tmux new-session -d -c $PREFIX -s $SESSION -n $SESSION
  tmux split-window -t $SESSION:1.0
  tmux resize-pane -t $SESSION:1.1 -D 10
  tmux split-window -h -t $SESSION:1.1

  tmux send-keys -t $SESSION:1.0 'nvim' C-m
  tmux send-keys -t $SESSION:1.1 'mix test' C-m
  tmux send-keys -t $SESSION:1.2 'iex -S mix phx.server' C-m

  echo "Session $SESSION started in $PREFIX"
}

function setup_emie {
  echo "Setup $1"
  PREFIX=$(pwd)
  SESSION=$(basename $1 | sed "s/\./_/g")
  tmux new-session -d -c $PREFIX -s $SESSION -n $SESSION
  tmux send-keys -t $SESSION:1.0 'source .setup_env && docker-compose up -d' C-m

  echo "Emie Session $SESSION started in $PREFIX"
}
# MAIN

# Start EEC instances
for WORKDIR in $WORKDIRS; do
  cd $WORKDIR && setup_workdir $WORKDIR || echo "Workdir $WORKDIR not found."
  tmux list-sessions
done

# Start emie-instances
EMIE_INSTANCES="$HOME/src/production-copies/ematrix-vart.voestalpine.com $HOME/src/production-copies/vabwg.kportal.io"
for WORKDIR in $EMIE_INSTANCES; do
  cd $WORKDIR && setup_emie $WORKDIR || echo "Workdir $WORKDIR not found."
  tmux list-sessions
done

# Start CLOUDFLARE tunnel
tmux new-session -d -c $HOME/cloudflare -s CLOUDFLARE -n CLOUDFLARE
tmux send-keys -t CLOUDFLARE:1.0 'cd $HOME/cloudflare && ./start_tunnel' C-m
echo "cloudflare tunnel started"