JoshL
JoshL

Reputation: 1499

Best way to use rails console with cloud foundry

We've been experimenting with CF over Heroku and running into some issues. One of them deals with accessing the rails console in a CF AI. We're using Pivotal's PWS and have tried a number of things, including:

cd app; export HOME=$(pwd); source .profile.d/0_ruby.sh; rails c

and

cd app; export HOME=$(pwd); source .profile.d/*.sh; rails c

Both of which are hit or miss and typically don't work.

It seems a bit ridiculous that it's THIS much work to access the rails console via CF. I feel like there has to be a better, faster way.

Does anyone have any tips?

For anyone saying we should cf ssh in, here is what happens:

vcap@2f4663e4-f876-490c-65e2-a498:~$ cd app
vcap@2f4663e4-f876-490c-65e2-a498:~/app$ ls .profile.d/000_multi-supply.sh  0_ruby.sh
vcap@2f4663e4-f876-490c-65e2-a498:~/app$ source .profile.d/0_ruby.sh
vcap@2f4663e4-f876-490c-65e2-a498:~/app$ cd ..
vcap@2f4663e4-f876-490c-65e2-a498:~$ rails c
bash: rails: command not found
vcap@2f4663e4-f876-490c-65e2-a498:~$ source app/.profile.d/000_multisupply.sh
vcap@2f4663e4-f876-490c-65e2-a498:~$ rails c
bash: rails: command not found

Upvotes: 1

Views: 840

Answers (1)

Daniel Mikusa
Daniel Mikusa

Reputation: 15006

As of writing this, to fire up a Rails console run cf ssh my-app -t -c "/tmp/lifecycle/launcher /home/vcap/app 'rails c' ''".

This will SSH into the container and use the lifecycle launcher, which sets up the environment for you, to execute the command.

Upvotes: 6

Related Questions