openshift/origin-server — pull request #3653 by mfojtik (2013-09-17 14:10:04+00:00)
Title: [WIP][DO_NOT_MERGE] Card origin_runtime_86 Ruby development mode

Hi,

This is a WIP of the Ruby/Rails in development mode proof of concept. The main goal here is to make deploying the Ruby/Rails applications faster when running in the development mode by disabling some of the deployment procedures.

For now, this set does:

* Pass the RAILS_ENV to Passenger, so you can run Rails app in different environment than 'production'
* Disable 'rake assets:precompile' when running in the development mode
* Detect changes in the Gemfile and disable 'bundle install' when in development mode
* Restart Apache when switching to development mode (and back to production) but not when doing regular 'git push'

To use this, you need to set the RAILS_ENV variable:

```
$ rhc env set RAILS_ENV=development
```

The you need to push/restart your application. The output should look like this:

```
~/ruby03 → git push
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 420 bytes | 0 bytes/s, done.
Total 5 (delta 3), reused 0 (delta 0)
remote: Ruby cartridge in development mode, skipping stop...
remote: Stopping MySQL cartridge
remote: Saving away previously bundled RubyGems
remote: Building Ruby cartridge
remote: Restoring previously bundled RubyGems (note: you can commit .openshift/markers/force_clean_build at the root of your repo to force a clean bundle)
remote: Skipping 'bundle install' because development mode is enabled...
remote: Starting application ruby03
remote: Starting MySQL cartridge
remote: The 'rake assets:precompile' is disabled when Ruby is in development mode.
remote: Ruby cartridge in development mode, skipping start...
To ssh://52385ac5e174c573b00000cf@ruby03-mfojtik.dev.rhcloud.com/~/git/ruby03.git/
bb8afcc..d5d49c9 master -> master
```

The deploy time went down from ~2 minutes to about 30 seconds. The app is restarted and `Rails.env` is reporting 'development'.

TODO:

* Deal with production vs. development databases
* Deal with the MySQL restarts when 'gemfile_modified' is false.