Browse Source

Added tests and web servers for rails

Richard Nienaber 11 years ago
parent
commit
027aaaa56b
35 changed files with 447 additions and 433 deletions
  1. 20 0
      frameworks/Ruby/rails/Gemfile
  2. 0 9
      frameworks/Ruby/rails/Gemfile-jruby
  3. 0 8
      frameworks/Ruby/rails/Gemfile-ruby
  4. 184 0
      frameworks/Ruby/rails/Gemfile.lock
  5. 1 1
      frameworks/Ruby/rails/README.md
  6. 10 5
      frameworks/Ruby/rails/app/controllers/hello_world_controller.rb
  7. 102 8
      frameworks/Ruby/rails/benchmark_config
  8. 4 4
      frameworks/Ruby/rails/config/database.yml
  9. 1 1
      frameworks/Ruby/rails/config/routes.rb
  10. 10 0
      frameworks/Ruby/rails/config/thin.yml
  11. 8 0
      frameworks/Ruby/rails/config/trinidad.yml
  12. 0 2
      frameworks/Ruby/rails/doc/README_FOR_APP
  13. 32 0
      frameworks/Ruby/rails/helper.py
  14. 2 2
      frameworks/Ruby/rails/install.sh
  15. 0 0
      frameworks/Ruby/rails/lib/tasks/.gitkeep
  16. 0 0
      frameworks/Ruby/rails/log/.gitkeep
  17. 0 0
      frameworks/Ruby/rails/public/.keep
  18. 0 26
      frameworks/Ruby/rails/public/404.html
  19. 0 26
      frameworks/Ruby/rails/public/422.html
  20. 0 25
      frameworks/Ruby/rails/public/500.html
  21. 0 0
      frameworks/Ruby/rails/public/favicon.ico
  22. 0 241
      frameworks/Ruby/rails/public/index.html
  23. 0 5
      frameworks/Ruby/rails/public/robots.txt
  24. 10 0
      frameworks/Ruby/rails/run_jruby_puma.py
  25. 10 0
      frameworks/Ruby/rails/run_mri_puma.py
  26. 13 0
      frameworks/Ruby/rails/run_thin.py
  27. 10 0
      frameworks/Ruby/rails/run_torqbox.py
  28. 10 0
      frameworks/Ruby/rails/run_trinidad.py
  29. 20 0
      frameworks/Ruby/rails/run_unicorn.py
  30. 0 6
      frameworks/Ruby/rails/script/rails
  31. 0 29
      frameworks/Ruby/rails/setup_jruby.py
  32. 0 35
      frameworks/Ruby/rails/setup_ruby.py
  33. 0 0
      frameworks/Ruby/rails/vendor/assets/javascripts/.gitkeep
  34. 0 0
      frameworks/Ruby/rails/vendor/assets/stylesheets/.gitkeep
  35. 0 0
      frameworks/Ruby/rails/vendor/plugins/.gitkeep

+ 20 - 0
frameworks/Ruby/rails/Gemfile

@@ -0,0 +1,20 @@
+source 'http://rubygems.org'
+
+platforms :jruby do
+  gem "activerecord-jdbcmysql-adapter", "~> 1.3.9", :require => false
+  gem 'torqbox', '0.1.7'
+  gem "trinidad", '1.4.6'
+end
+
+platforms :ruby do
+  gem 'mysql2', '0.3.16'
+  gem "unicorn", '4.8.3'
+  gem "thin", '1.6.2'
+end
+
+gem "puma", '2.9.0'
+
+gem "activerecord-import", '0.5.0'
+gem 'activerecord', '4.1.4', :require => 'active_record'
+
+gem 'rails', '~> 4.1.4'

+ 0 - 9
frameworks/Ruby/rails/Gemfile-jruby

@@ -1,9 +0,0 @@
-source 'https://rubygems.org'
-
-gem 'rails', '~> 4.1.4'
-gem 'activerecord-jdbc-adapter', '~> 1.3.9'
-gem 'jdbc-mysql', '~> 5.1.30'
-
-group :server do
-  gem 'torqbox', '0.1.7', :require => false
-end

+ 0 - 8
frameworks/Ruby/rails/Gemfile-ruby

@@ -1,8 +0,0 @@
-source 'https://rubygems.org'
-
-gem 'rails', '~> 4.1.4'
-gem 'mysql2', '~> 0.3.16'
-
-group :server do
-  gem 'unicorn', '~> 4.8.3', :require => false
-end

+ 184 - 0
frameworks/Ruby/rails/Gemfile.lock

@@ -0,0 +1,184 @@
+GEM
+  remote: http://rubygems.org/
+  specs:
+    actionmailer (4.1.4)
+      actionpack (= 4.1.4)
+      actionview (= 4.1.4)
+      mail (~> 2.5.4)
+    actionpack (4.1.4)
+      actionview (= 4.1.4)
+      activesupport (= 4.1.4)
+      rack (~> 1.5.2)
+      rack-test (~> 0.6.2)
+    actionview (4.1.4)
+      activesupport (= 4.1.4)
+      builder (~> 3.1)
+      erubis (~> 2.7.0)
+    activemodel (4.1.4)
+      activesupport (= 4.1.4)
+      builder (~> 3.1)
+    activerecord (4.1.4)
+      activemodel (= 4.1.4)
+      activesupport (= 4.1.4)
+      arel (~> 5.0.0)
+    activerecord-import (0.5.0)
+      activerecord (>= 3.0)
+    activerecord-jdbc-adapter (1.3.9)
+      activerecord (>= 2.2)
+    activerecord-jdbcmysql-adapter (1.3.9)
+      activerecord-jdbc-adapter (~> 1.3.9)
+      jdbc-mysql (>= 5.1.22)
+    activesupport (4.1.4)
+      i18n (~> 0.6, >= 0.6.9)
+      json (~> 1.7, >= 1.7.7)
+      minitest (~> 5.1)
+      thread_safe (~> 0.1)
+      tzinfo (~> 1.1)
+    arel (5.0.1.20140414130214)
+    builder (3.2.2)
+    daemons (1.1.9)
+    erubis (2.7.0)
+    eventmachine (1.0.3)
+    hike (1.2.3)
+    i18n (0.6.11)
+    jdbc-mysql (5.1.31)
+    jruby-rack (1.1.16)
+    json (1.8.1)
+    json (1.8.1-java)
+    kgio (2.9.2)
+    mail (2.5.4)
+      mime-types (~> 1.16)
+      treetop (~> 1.4.8)
+    mime-types (1.25.1)
+    minitest (5.4.0)
+    multi_json (1.10.1)
+    mysql2 (0.3.16)
+    polyglot (0.3.5)
+    puma (2.9.0)
+      rack (>= 1.1, < 2.0)
+    puma (2.9.0-java)
+      rack (>= 1.1, < 2.0)
+    rack (1.5.2)
+    rack-test (0.6.2)
+      rack (>= 1.0)
+    rails (4.1.4)
+      actionmailer (= 4.1.4)
+      actionpack (= 4.1.4)
+      actionview (= 4.1.4)
+      activemodel (= 4.1.4)
+      activerecord (= 4.1.4)
+      activesupport (= 4.1.4)
+      bundler (>= 1.3.0, < 2.0)
+      railties (= 4.1.4)
+      sprockets-rails (~> 2.0)
+    railties (4.1.4)
+      actionpack (= 4.1.4)
+      activesupport (= 4.1.4)
+      rake (>= 0.8.7)
+      thor (>= 0.18.1, < 2.0)
+    raindrops (0.13.0)
+    rake (10.3.2)
+    sprockets (2.12.1)
+      hike (~> 1.2)
+      multi_json (~> 1.0)
+      rack (~> 1.0)
+      tilt (~> 1.1, != 1.3.0)
+    sprockets-rails (2.1.3)
+      actionpack (>= 3.0)
+      activesupport (>= 3.0)
+      sprockets (~> 2.8)
+    thin (1.6.2)
+      daemons (>= 1.0.9)
+      eventmachine (>= 1.0.0)
+      rack (>= 1.0.0)
+    thor (0.19.1)
+    thread_safe (0.3.4)
+    thread_safe (0.3.4-java)
+    tilt (1.4.1)
+    torqbox (0.1.7-java)
+      rack (>= 1.4.0, < 2.0)
+    treetop (1.4.15)
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+      polyglot (>= 0.3.1)
+    trinidad (1.4.6)
+      jruby-rack (~> 1.1.13)
+      trinidad_jars (>= 1.3.0, < 1.5.0)
+    trinidad_jars (1.4.0)
+    tzinfo (1.2.2)
+      thread_safe (~> 0.1)
+    unicorn (4.8.3)
+      kgio (~> 2.6)
+      rack
+      raindrops (~> 0.7)
+
+PLATFORMS
+  java
+  ruby
+
+DEPENDENCIES
+  activerecord (= 4.1.4)
+  activerecord-import (= 0.5.0)
+  activerecord-jdbcmysql-adapter (~> 1.3.9)
+  mysql2 (= 0.3.16)
+  puma (= 2.9.0)
+  rails (~> 4.1.4)
+  thin (= 1.6.2)
+  torqbox (= 0.1.7)
+  trinidad (= 1.4.6)
+  unicorn (= 4.8.3)

+ 1 - 1
frameworks/Ruby/rails/README.md

@@ -14,7 +14,7 @@ This is the Ruby on Rails portion of a [benchmarking test suite](../) comparing
 The tests were run with:
 * [Ruby 2.1.2](http://www.ruby-lang.org/)
 * [JRuby 1.7.13](http://jruby.org/)
-* [Rails 4.1.x](http://rubyonrails.org/)
+* [Rails 4.1.4](http://rubyonrails.org/)
 * [Unicorn 4.8.3](http://unicorn.bogomips.org/)
 * [TorqBox 0.1.7](http://torquebox.org/torqbox/)
 * [MySQL 5.5](https://dev.mysql.com/)

+ 10 - 5
frameworks/Ruby/rails/app/controllers/hello_world_controller.rb

@@ -1,5 +1,9 @@
 class HelloWorldController < ApplicationController
 
+  def plaintext
+    render :plain => "Hello, World!"
+  end
+
   def json
     render :json => {:message => "Hello, World!"}
   end
@@ -28,16 +32,17 @@ class HelloWorldController < ApplicationController
 
   def update
     queries = (params[:queries] || 1).to_i
+    queries = 1 if queries < 1
+    queries = 500 if queries > 500
 
-    results = (1..queries).map do
+    worlds = (1..queries).map do
       # get a random row from the database, which we know has 10000
       # rows with ids 1 - 10000
       world = World.find(Random.rand(10000) + 1)
       world.randomNumber = Random.rand(10000) + 1
-      world.save
-
       world
     end
-    render :json => results
+    World.import worlds, :on_duplicate_key_update => [:randomNumber]
+    render :json => worlds
   end
-end
+end

+ 102 - 8
frameworks/Ruby/rails/benchmark_config

@@ -1,13 +1,37 @@
 {
   "framework": "rails",
   "tests": [{
-    "ruby": {
-      "setup_file": "setup_ruby",
+    "jruby-puma": {
+      "setup_file": "run_jruby_puma",
       "json_url": "/hello_world/json",
       "db_url": "/hello_world/db",
       "query_url": "/hello_world/db?queries=",
       "fortune_url": "/fortune",
       "update_url": "/update?queries=",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MySQL",
+      "framework": "rails",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "JRuby",
+      "webserver": "Puma",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "puma-jruby-rails",
+      "notes": "",
+      "versus": "rack-puma-jruby"
+    },
+    "ruby-puma": {
+      "setup_file": "run_mri_puma",
+      "json_url": "/hello_world/json",
+      "db_url": "/hello_world/db",
+      "query_url": "/hello_world/db?queries=",
+      "fortune_url": "/fortune",
+      "update_url": "/update?queries=",
+      "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Fullstack",
@@ -16,20 +40,44 @@
       "language": "Ruby",
       "orm": "Full",
       "platform": "Rack",
-      "webserver": "Unicorn",
+      "webserver": "Puma",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "rails",
+      "display_name": "puma-mri-rails",
       "notes": "",
-      "versus": "rack-unicorn"
+      "versus": "rack-puma"
+    },
+    "thin": {
+      "setup_file": "run_thin",
+      "json_url": "/hello_world/json",
+      "db_url": "/hello_world/db",
+      "query_url": "/hello_world/db?queries=",
+      "fortune_url": "/fortune",
+      "update_url": "/update?queries=",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MySQL",
+      "framework": "rails",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "Rack",
+      "webserver": "Thin",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "thin-rails",
+      "notes": "",
+      "versus": "rack-thin"
     },
-    "jruby": {
-      "setup_file": "setup_jruby",
+    "torqbox": {
+      "setup_file": "run_torqbox",
       "json_url": "/hello_world/json",
       "db_url": "/hello_world/db",
       "query_url": "/hello_world/db?queries=",
       "fortune_url": "/fortune",
       "update_url": "/update?queries=",
+      "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Fullstack",
@@ -41,9 +89,55 @@
       "webserver": "TorqBox",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "rails",
+      "display_name": "torqbox-rails",
       "notes": "",
       "versus": "rack-torqbox"
+    },
+    "trinidad": {
+      "setup_file": "run_trinidad",
+      "json_url": "/hello_world/json",
+      "db_url": "/hello_world/db",
+      "query_url": "/hello_world/db?queries=",
+      "fortune_url": "/fortune",
+      "update_url": "/update?queries=",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MySQL",
+      "framework": "rails",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "JRuby",
+      "webserver": "Trinidad",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "trinidad-rails",
+      "notes": "",
+      "versus": "rack-trinidad"
+    },
+    "unicorn": {
+      "setup_file": "run_unicorn",
+      "json_url": "/hello_world/json",
+      "db_url": "/hello_world/db",
+      "query_url": "/hello_world/db?queries=",
+      "fortune_url": "/fortune",
+      "update_url": "/update?queries=",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MySQL",
+      "framework": "rails",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "Rack",
+      "webserver": "Unicorn",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "unicorn-rails",
+      "notes": "",
+      "versus": "rack-unicorn"
     }
   }]
 }

+ 4 - 4
frameworks/Ruby/rails/config/database.yml

@@ -1,18 +1,18 @@
 
 development:
-  adapter: mysql2
+  adapter: <%= RUBY_PLATFORM == 'java' ? 'jdbcmysql' : 'mysql2' %>
   database: hello_world
   username: benchmarkdbuser
   password: benchmarkdbpass
-  host: localhost
+  host: <%= ENV['DB_HOST'] %>
   pool: 5
   timeout: 5000
 
 production:
-  adapter: mysql2
+  adapter: <%= RUBY_PLATFORM == 'java' ? 'jdbcmysql' : 'mysql2' %>
   database: hello_world
   username: benchmarkdbuser
   password: benchmarkdbpass
-  host: localhost
+  host: <%= ENV['DB_HOST'] %>
   pool: 256
   timeout: 5000

+ 1 - 1
frameworks/Ruby/rails/config/routes.rb

@@ -58,5 +58,5 @@ Rails.application.routes.draw do
   get "hello_world/db"
   get "fortune" => "hello_world#fortune"
   get "update" => "hello_world#update"
-
+  get "plaintext" => "hello_world#plaintext"
 end

+ 10 - 0
frameworks/Ruby/rails/config/thin.yml

@@ -0,0 +1,10 @@
+--- 
+timeout: 30
+wait: 30
+max_conns: 1024
+max_persistent_conns: 512
+environment: production
+port: 8080
+servers: 8
+log: /tmp/thin.log
+quiet: true

+ 8 - 0
frameworks/Ruby/rails/config/trinidad.yml

@@ -0,0 +1,8 @@
+---
+  port: 8080
+  threadsafe: true
+  environment: production
+  http:
+    address: '*'
+  logging:
+    level: SEVERE

+ 0 - 2
frameworks/Ruby/rails/doc/README_FOR_APP

@@ -1,2 +0,0 @@
-Use this README file to introduce your application and point to useful places in the API for learning more.
-Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.

+ 32 - 0
frameworks/Ruby/rails/helper.py

@@ -0,0 +1,32 @@
+import os
+import subprocess
+from collections import namedtuple
+
+import setup_util
+
+Command = namedtuple('Command', ['command', 'wait_for_exit'])
+
+def set_database_host(args):
+  database_host = args.database_host or 'localhost'
+  database_file = os.path.join(args.troot, 'config', 'database.yml')
+  setup_util.replace_text(database_file, "  host:.*", "  host: " + database_host)
+
+def run(commands, logfile, errfile, cwd):
+  try:
+    for command in commands:      
+      if command.wait_for_exit:
+        subprocess.check_call(command.command, shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
+      else:
+        subprocess.Popen(command.command, shell=True, cwd=cwd, stderr=errfile, stdout=logfile)
+  except subprocess.CalledProcessError:
+    return 1
+  return 0
+
+def stop(partial_command, logfile, errfile):
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if partial_command in line and 'run-tests' not in line:
+      pid = int(line.split(None, 2)[1])
+      os.kill(pid, 15)
+  return 0

+ 2 - 2
frameworks/Ruby/rails/install.sh

@@ -3,7 +3,7 @@
 fw_depends rvm nginx java
 
 rvm install 2.1.2
-rvm 2.1.2 do bundle install --gemfile=$TROOT/Gemfile-ruby
+rvm 2.1.2 do bundle install --gemfile=$TROOT/Gemfile
 
 rvm install jruby-1.7.13
-rvm jruby-1.7.13 do bundle install --gemfile=$TROOT/Gemfile-jruby
+rvm jruby-1.7.13 do bundle install --gemfile=$TROOT/Gemfile

+ 0 - 0
frameworks/Ruby/rails/lib/tasks/.gitkeep


+ 0 - 0
frameworks/Ruby/rails/log/.gitkeep


+ 0 - 0
frameworks/Ruby/rails/lib/assets/.gitkeep → frameworks/Ruby/rails/public/.keep


+ 0 - 26
frameworks/Ruby/rails/public/404.html

@@ -1,26 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>The page you were looking for doesn't exist (404)</title>
-  <style type="text/css">
-    body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
-    div.dialog {
-      width: 25em;
-      padding: 0 4em;
-      margin: 4em auto 0 auto;
-      border: 1px solid #ccc;
-      border-right-color: #999;
-      border-bottom-color: #999;
-    }
-    h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
-  </style>
-</head>
-
-<body>
-  <!-- This file lives in public/404.html -->
-  <div class="dialog">
-    <h1>The page you were looking for doesn't exist.</h1>
-    <p>You may have mistyped the address or the page may have moved.</p>
-  </div>
-</body>
-</html>

+ 0 - 26
frameworks/Ruby/rails/public/422.html

@@ -1,26 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>The change you wanted was rejected (422)</title>
-  <style type="text/css">
-    body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
-    div.dialog {
-      width: 25em;
-      padding: 0 4em;
-      margin: 4em auto 0 auto;
-      border: 1px solid #ccc;
-      border-right-color: #999;
-      border-bottom-color: #999;
-    }
-    h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
-  </style>
-</head>
-
-<body>
-  <!-- This file lives in public/422.html -->
-  <div class="dialog">
-    <h1>The change you wanted was rejected.</h1>
-    <p>Maybe you tried to change something you didn't have access to.</p>
-  </div>
-</body>
-</html>

+ 0 - 25
frameworks/Ruby/rails/public/500.html

@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>We're sorry, but something went wrong (500)</title>
-  <style type="text/css">
-    body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
-    div.dialog {
-      width: 25em;
-      padding: 0 4em;
-      margin: 4em auto 0 auto;
-      border: 1px solid #ccc;
-      border-right-color: #999;
-      border-bottom-color: #999;
-    }
-    h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
-  </style>
-</head>
-
-<body>
-  <!-- This file lives in public/500.html -->
-  <div class="dialog">
-    <h1>We're sorry, but something went wrong.</h1>
-  </div>
-</body>
-</html>

+ 0 - 0
frameworks/Ruby/rails/public/favicon.ico


+ 0 - 241
frameworks/Ruby/rails/public/index.html

@@ -1,241 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <title>Ruby on Rails: Welcome aboard</title>
-    <style type="text/css" media="screen">
-      body {
-        margin: 0;
-        margin-bottom: 25px;
-        padding: 0;
-        background-color: #f0f0f0;
-        font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
-        font-size: 13px;
-        color: #333;
-      }
-
-      h1 {
-        font-size: 28px;
-        color: #000;
-      }
-
-      a  {color: #03c}
-      a:hover {
-        background-color: #03c;
-        color: white;
-        text-decoration: none;
-      }
-
-
-      #page {
-        background-color: #f0f0f0;
-        width: 750px;
-        margin: 0;
-        margin-left: auto;
-        margin-right: auto;
-      }
-
-      #content {
-        float: left;
-        background-color: white;
-        border: 3px solid #aaa;
-        border-top: none;
-        padding: 25px;
-        width: 500px;
-      }
-
-      #sidebar {
-        float: right;
-        width: 175px;
-      }
-
-      #footer {
-        clear: both;
-      }
-
-      #header, #about, #getting-started {
-        padding-left: 75px;
-        padding-right: 30px;
-      }
-
-
-      #header {
-        background-image: url("assets/rails.png");
-        background-repeat: no-repeat;
-        background-position: top left;
-        height: 64px;
-      }
-      #header h1, #header h2 {margin: 0}
-      #header h2 {
-        color: #888;
-        font-weight: normal;
-        font-size: 16px;
-      }
-
-
-      #about h3 {
-        margin: 0;
-        margin-bottom: 10px;
-        font-size: 14px;
-      }
-
-      #about-content {
-        background-color: #ffd;
-        border: 1px solid #fc0;
-        margin-left: -55px;
-        margin-right: -10px;
-      }
-      #about-content table {
-        margin-top: 10px;
-        margin-bottom: 10px;
-        font-size: 11px;
-        border-collapse: collapse;
-      }
-      #about-content td {
-        padding: 10px;
-        padding-top: 3px;
-        padding-bottom: 3px;
-      }
-      #about-content td.name  {color: #555}
-      #about-content td.value {color: #000}
-
-      #about-content ul {
-        padding: 0;
-        list-style-type: none;
-      }
-
-      #about-content.failure {
-        background-color: #fcc;
-        border: 1px solid #f00;
-      }
-      #about-content.failure p {
-        margin: 0;
-        padding: 10px;
-      }
-
-
-      #getting-started {
-        border-top: 1px solid #ccc;
-        margin-top: 25px;
-        padding-top: 15px;
-      }
-      #getting-started h1 {
-        margin: 0;
-        font-size: 20px;
-      }
-      #getting-started h2 {
-        margin: 0;
-        font-size: 14px;
-        font-weight: normal;
-        color: #333;
-        margin-bottom: 25px;
-      }
-      #getting-started ol {
-        margin-left: 0;
-        padding-left: 0;
-      }
-      #getting-started li {
-        font-size: 18px;
-        color: #888;
-        margin-bottom: 25px;
-      }
-      #getting-started li h2 {
-        margin: 0;
-        font-weight: normal;
-        font-size: 18px;
-        color: #333;
-      }
-      #getting-started li p {
-        color: #555;
-        font-size: 13px;
-      }
-
-
-      #sidebar ul {
-        margin-left: 0;
-        padding-left: 0;
-      }
-      #sidebar ul h3 {
-        margin-top: 25px;
-        font-size: 16px;
-        padding-bottom: 10px;
-        border-bottom: 1px solid #ccc;
-      }
-      #sidebar li {
-        list-style-type: none;
-      }
-      #sidebar ul.links li {
-        margin-bottom: 5px;
-      }
-
-      .filename {
-        font-style: italic;
-      }
-    </style>
-    <script type="text/javascript">
-      function about() {
-        info = document.getElementById('about-content');
-        if (window.XMLHttpRequest)
-          { xhr = new XMLHttpRequest(); }
-        else
-          { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
-        xhr.open("GET","rails/info/properties",false);
-        xhr.send("");
-        info.innerHTML = xhr.responseText;
-        info.style.display = 'block'
-      }
-    </script>
-  </head>
-  <body>
-    <div id="page">
-      <div id="sidebar">
-        <ul id="sidebar-items">
-          <li>
-            <h3>Browse the documentation</h3>
-            <ul class="links">
-              <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
-              <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
-              <li><a href="http://www.ruby-doc.org/core/">Ruby core</a></li>
-              <li><a href="http://www.ruby-doc.org/stdlib/">Ruby standard library</a></li>
-            </ul>
-          </li>
-        </ul>
-      </div>
-
-      <div id="content">
-        <div id="header">
-          <h1>Welcome aboard</h1>
-          <h2>You&rsquo;re riding Ruby on Rails!</h2>
-        </div>
-
-        <div id="about">
-          <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
-          <div id="about-content" style="display: none"></div>
-        </div>
-
-        <div id="getting-started">
-          <h1>Getting started</h1>
-          <h2>Here&rsquo;s how to get rolling:</h2>
-
-          <ol>
-            <li>
-              <h2>Use <code>rails generate</code> to create your models and controllers</h2>
-              <p>To see all available options, run it without parameters.</p>
-            </li>
-
-            <li>
-              <h2>Set up a default route and remove <span class="filename">public/index.html</span></h2>
-              <p>Routes are set up in <span class="filename">config/routes.rb</span>.</p>
-            </li>
-
-            <li>
-              <h2>Create your database</h2>
-              <p>Run <code>rake db:create</code> to create your database. If you're not using SQLite (the default), edit <span class="filename">config/database.yml</span> with your username and password.</p>
-            </li>
-          </ol>
-        </div>
-      </div>
-
-      <div id="footer">&nbsp;</div>
-    </div>
-  </body>
-</html>

+ 0 - 5
frameworks/Ruby/rails/public/robots.txt

@@ -1,5 +0,0 @@
-# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
-#
-# To ban all spiders from the entire site uncomment the next two lines:
-# User-Agent: *
-# Disallow: /

+ 10 - 0
frameworks/Ruby/rails/run_jruby_puma.py

@@ -0,0 +1,10 @@
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm jruby-1.7.13 do bundle exec puma -b tcp://0.0.0.0:8080 -e production"
+  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('puma', logfile, errfile)

+ 10 - 0
frameworks/Ruby/rails/run_mri_puma.py

@@ -0,0 +1,10 @@
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm ruby-2.1.2 do bundle exec puma -t 8:32 -w 8 --preload -b tcp://0.0.0.0:8080 -e production"
+  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('puma', logfile, errfile)

+ 13 - 0
frameworks/Ruby/rails/run_thin.py

@@ -0,0 +1,13 @@
+import os
+
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm ruby-2.1.2 do bundle exec thin start -C config/thin.yml"
+  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  helper.run([Command('rm -rf tmp/*', True)], logfile, errfile, os.environ['TROOT'])
+  return helper.stop('thin', logfile, errfile)

+ 10 - 0
frameworks/Ruby/rails/run_torqbox.py

@@ -0,0 +1,10 @@
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm jruby-1.7.13 do bundle exec torqbox -b 0.0.0.0 -E production"
+  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('torqbox', logfile, errfile)

+ 10 - 0
frameworks/Ruby/rails/run_trinidad.py

@@ -0,0 +1,10 @@
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm jruby-1.7.13 do bundle exec trinidad --config config/trinidad.yml"
+  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('trinidad', logfile, errfile)

+ 20 - 0
frameworks/Ruby/rails/run_unicorn.py

@@ -0,0 +1,20 @@
+import os
+import setup_util
+
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm 2.1.2 do bundle exec unicorn_rails -E production -c $TROOT/config/unicorn.rb"
+
+  commands = [
+    Command("sudo /usr/local/nginx/sbin/nginx -c $TROOT/config/nginx.conf", True),
+    Command(start_server, False)
+  ]
+
+  return helper.run(commands, logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  helper.run([Command("sudo /usr/local/nginx/sbin/nginx -s stop -c $TROOT/config/nginx.conf", True)], logfile, errfile, os.environ['TROOT'])
+  return helper.stop('unicorn', logfile, errfile)

+ 0 - 6
frameworks/Ruby/rails/script/rails

@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
-
-APP_PATH = File.expand_path('../../config/application',  __FILE__)
-require File.expand_path('../../config/boot',  __FILE__)
-require 'rails/commands'

+ 0 - 29
frameworks/Ruby/rails/setup_jruby.py

@@ -1,29 +0,0 @@
-
-import subprocess
-import sys
-import os
-import setup_util
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("rails/config/database.yml", "host: .*", "host: " + args.database_host)
-
-  try:
-    subprocess.check_call("cp Gemfile-jruby Gemfile", shell=True, cwd="rails", stderr=errfile, stdout=logfile)
-    subprocess.check_call("cp Gemfile-jruby.lock Gemfile.lock", shell=True, cwd="rails", stderr=errfile, stdout=logfile)
-    subprocess.Popen("rvm jruby-1.7.13 do bundle exec torqbox -b 0.0.0.0 -E production", shell=True, cwd="rails", stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-def stop(logfile, errfile):
-  try:
-    p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-    out, err = p.communicate()
-    for line in out.splitlines():
-      if 'torqbox' in line:
-        pid = int(line.split(None, 2)[1])
-        os.kill(pid, 15)
-    subprocess.check_call("rm -f Gemfile", shell=True, cwd="rails", stderr=errfile, stdout=logfile)
-    subprocess.check_call("rm -f Gemfile.lock", shell=True, cwd="rails", stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1

+ 0 - 35
frameworks/Ruby/rails/setup_ruby.py

@@ -1,35 +0,0 @@
-
-import subprocess
-import sys
-import re
-import os
-import setup_util
-import time
-
-def start(args, logfile, errfile):
-  
-  setup_util.replace_text("rails/config/database.yml", "host: .*", "host: " + args.database_host)
-
-  try:
-    subprocess.check_call("cp Gemfile-ruby Gemfile", shell=True, cwd="rails", stderr=errfile, stdout=logfile)
-    subprocess.check_call("cp Gemfile-ruby.lock Gemfile.lock", shell=True, cwd="rails", stderr=errfile, stdout=logfile)
-    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c $TROOT/config/nginx.conf", shell=True, stderr=errfile, stdout=logfile)
-    subprocess.Popen("rvm 2.1.2 do bundle exec unicorn_rails -E production -c $TROOT/config/unicorn.rb", shell=True, cwd="rails", stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-def stop(logfile, errfile):
-  subprocess.call("sudo /usr/local/nginx/sbin/nginx -c $TROOT/config/nginx.conf -s stop", shell=True, stderr=errfile, stdout=logfile)
-  try:
-    p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-    out, err = p.communicate()
-    for line in out.splitlines():
-      if 'unicorn' in line and 'master' in line:
-        pid = int(line.split(None, 2)[1])
-        os.kill(pid, 15)
-    subprocess.check_call("rm -f Gemfile", shell=True, cwd="rails")
-    subprocess.check_call("rm -f Gemfile.lock", shell=True, cwd="rails")
-
-    return 0
-  except subprocess.CalledProcessError:
-    return 1

+ 0 - 0
frameworks/Ruby/rails/vendor/assets/javascripts/.gitkeep


+ 0 - 0
frameworks/Ruby/rails/vendor/assets/stylesheets/.gitkeep


+ 0 - 0
frameworks/Ruby/rails/vendor/plugins/.gitkeep