Betafish
Betafish

Reputation: 1262

Passing commands to deployed Ruby on Rails App in Bluemix

Finally, with the help of SO member, JeffSloyer, I was able to deploy my RoR app on to bluemix. There seems to be an additional problem with the RoR app. I cant login as admin in this app.

http://csw-events.mybluemix.net/sign_in

The question here is not about the app itself, I have found a solution from the forum dedicated to this RoR app(Currently, in-active) -> SOLUTION.

The question is 1: Can I pass commands to an already deployed app on Bluemix using CF something like this

 cf -c "User.last.update_attribute(:admin, true)"

If not, What are the alternatives for passing such commands

As for this eg it is

bundle exec rails console
User.last.update_attribute(:admin, true)

Upvotes: 0

Views: 293

Answers (2)

DirkBlaauw
DirkBlaauw

Reputation: 17

You could also push the app again and add a command with the -c option:

cf push -f manifest.yml -c "User.last.update_attribute(:admin, true)"

It would mean some downtime but only a very limited amount of time.

If the app does not run anymore with a consequent push, run the same cf command with -c "null", Cloud Foundry is a bit buggy that way.

If it is only a once off command you want to pass this would be the recommended way, instead of putting it in the manifest file.

Upvotes: 0

Ram Vennam
Ram Vennam

Reputation: 3546

You can not pass commands to an already running CF application.

You can have the buildpack run commands for you at the start of the application by creating a manifest.yml file at the root of your application and specifying the command.

Sample manifest.yml:

---
applications:
- name: my-rails-app
  command: bundle exec rake cf:on_first_instance db:migrate && bundle exec rails s -p $PORT -e $RAILS_ENV

Tips for Ruby Developers

Upvotes: 1

Related Questions