ruby_newbie
ruby_newbie

Reputation: 3285

Using tmuxinator to run multiple rails applications with different versions

I have a project that has 3 rails applications all of which run on different ruby/rails versions. I am trying to set up a single script to start all 3 projects. I started by just writing the shell script below:

mysql.server start
echo first argument: $1

open -a /Applications/Utilities/Terminal.app redis-server
open -a /Applications/Utilities/Terminal.app /Users/acumendigital/org/shell_scripts/application1.sh --args $1
open -a /Applications/Utilities/Terminal.app /Users/acumendigital/org/shell_scripts/application2.sh --args $1

which will take in an argument(the branch of the current release) and run the following:

cd /Users/acumendigital/org/application1
git fetch origin $1
git stash
git checkout $1
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then

  # First try to load from a user install
  source "$HOME/.rvm/scripts/rvm"

elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then

  # Then try to load from a root install
  source "/usr/local/rvm/scripts/rvm"

else

  printf "ERROR: An RVM installation was not found.\n"

fi
rvm install ruby-1.9.3-p551
rvm use ruby-1.9.3-p551
gem install bundler
bundle install
rake db:migrate
bundle exec rails s -p 3001

The problem is that when I run the process like this, it is not being run in a shell so I have to do the rvm and ruby version install each time. This negates the time savings that the script is designed to create. I was able to get tmuxinator to run the same scripts but it looks like tmuxinator will only allow me to set one ruby version in the pre_window. That means I still have to install rvm ect each time. What I have in my tmuxinator config currently is:

name: work
root: ~/org/

windows:
  - application1: cd shell_scripts && ./application1.sh
  - application2: cd shell_scripts && ./application2.sh 

What is the best way to run these scripts as shell sessions but with different versions of ruby?

Please ask if additional information is needed and I will provide it.
Thanks for looking!

Upvotes: 2

Views: 154

Answers (0)

Related Questions