Browse Source

Extended tests and added web servers for Sinatra

Richard Nienaber 11 years ago
parent
commit
ffe159c221

+ 24 - 0
frameworks/Ruby/sinatra/Gemfile

@@ -0,0 +1,24 @@
+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 "sinatra-activerecord", '2.0.2'
+gem 'sinatra', '1.4.5'
+gem 'sinatra-contrib', '1.4.2'
+
+gem 'slim', '2.0.3'

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

@@ -1,9 +0,0 @@
-source 'https://rubygems.org'
-gem 'sinatra', '1.3.4'
-gem 'sinatra-contrib', '1.3.2'
-gem 'torqbox', '0.1.7'
-gem 'activerecord-jdbcmysql-adapter', '1.2.6'
-gem "sinatra-activerecord", "1.2.2"
-gem "rubyzip", "~> 1.0.0"
-gem "zip-zip", "~> 0.1"
-

+ 0 - 9
frameworks/Ruby/sinatra/Gemfile-ruby

@@ -1,9 +0,0 @@
-source 'https://rubygems.org'
-gem 'sinatra', '1.3.4'
-gem 'sinatra-contrib', '1.3.2'
-gem 'activerecord', '3.2.11'
-gem 'rack', '1.5.1'
-gem 'mysql2', '0.3.11'
-gem 'passenger', '4.0.19'
-gem "sinatra-activerecord", "1.2.2"
-gem "unicorn", "4.6.2"

+ 103 - 0
frameworks/Ruby/sinatra/Gemfile.lock

@@ -0,0 +1,103 @@
+GEM
+  remote: http://rubygems.org/
+  specs:
+    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)
+    backports (3.6.0)
+    builder (3.2.2)
+    daemons (1.1.9)
+    eventmachine (1.0.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)
+    minitest (5.4.0)
+    multi_json (1.10.1)
+    mysql2 (0.3.16)
+    puma (2.9.0)
+      rack (>= 1.1, < 2.0)
+    puma (2.9.0-java)
+      rack (>= 1.1, < 2.0)
+    rack (1.5.2)
+    rack-protection (1.5.3)
+      rack
+    rack-test (0.6.2)
+      rack (>= 1.0)
+    raindrops (0.13.0)
+    sinatra (1.4.5)
+      rack (~> 1.4)
+      rack-protection (~> 1.4)
+      tilt (~> 1.3, >= 1.3.4)
+    sinatra-activerecord (2.0.2)
+      activerecord (>= 3.2)
+      sinatra (~> 1.0)
+    sinatra-contrib (1.4.2)
+      backports (>= 2.0)
+      multi_json
+      rack-protection
+      rack-test
+      sinatra (~> 1.4.0)
+      tilt (~> 1.3)
+    slim (2.0.3)
+      temple (~> 0.6.6)
+      tilt (>= 1.3.3, < 2.1)
+    temple (0.6.8)
+    thin (1.6.2)
+      daemons (>= 1.0.9)
+      eventmachine (>= 1.0.0)
+      rack (>= 1.0.0)
+    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)
+    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)
+  sinatra (= 1.4.5)
+  sinatra-activerecord (= 2.0.2)
+  sinatra-contrib (= 1.4.2)
+  slim (= 2.0.3)
+  thin (= 1.6.2)
+  torqbox (= 0.1.7)
+  trinidad (= 1.4.6)
+  unicorn (= 4.8.3)

+ 105 - 9
frameworks/Ruby/sinatra/benchmark_config

@@ -1,11 +1,36 @@
 {
   "framework": "sinatra",
   "tests": [{
-    "ruby": {
-      "setup_file": "setup_ruby",
+    "puma-jruby": {
+      "setup_file": "run_jruby_puma",
       "json_url": "/json",
       "db_url": "/db",
       "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "sinatra",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "JRuby",
+      "webserver": "Puma",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "sinatra-jruby-puma",
+      "notes": "",
+      "versus": "rack-jruby-puma"
+    },
+    "puma": {
+      "setup_file": "run_mri_puma",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
       "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
@@ -15,18 +40,43 @@
       "language": "Ruby",
       "orm": "Full",
       "platform": "Rack",
-      "webserver": "Unicorn",
+      "webserver": "Puma",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "sinatra",
+      "display_name": "sinatra-puma",
       "notes": "",
-      "versus": "rack-unicorn"
+      "versus": "rack-puma"
+    },
+    "thin": {
+      "setup_file": "run_thin",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "sinatra",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "Rack",
+      "webserver": "Thin",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "sinatra-thin",
+      "notes": "",
+      "versus": "rack-thin"
     },
-    "jruby": {
-      "setup_file": "setup_jruby",
+    "torqbox": {
+      "setup_file": "run_torqbox",
       "json_url": "/json",
       "db_url": "/db",
       "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
       "plaintext_url": "/plaintext",
       "port": 8080,
       "approach": "Realistic",
@@ -39,9 +89,55 @@
       "webserver": "TorqBox",
       "os": "Linux",
       "database_os": "Linux",
-      "display_name": "sinatra-jruby",
+      "display_name": "sinatra-torqbox",
       "notes": "",
       "versus": "rack-torqbox"
-    }
+    },
+    "trinidad": {
+      "setup_file": "run_trinidad",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "sinatra",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "JRuby",
+      "webserver": "Trinidad",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "sinatra-trinidad",
+      "notes": "",
+      "versus": "rack-trinidad"
+    },
+    "unicorn": {
+      "setup_file": "run_unicorn",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=", 
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "sinatra",
+      "language": "Ruby",
+      "orm": "Full",
+      "platform": "Rack",
+      "webserver": "Unicorn",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "sinatra-unicorn",
+      "notes": "",
+      "versus": "rack-unicorn"
+    }    
   }]
 }

+ 3 - 0
frameworks/Ruby/sinatra/config/puma.rb

@@ -0,0 +1,3 @@
+environment 'production'
+threads 8, 32
+bind 'tcp://0.0.0.0:8080'

+ 10 - 0
frameworks/Ruby/sinatra/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/sinatra/config/trinidad.yml

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

+ 3 - 48
frameworks/Ruby/sinatra/config/unicorn.rb

@@ -1,52 +1,7 @@
 worker_processes 8
 listen "/tmp/.sock", :backlog => 256
 preload_app true
-GC.respond_to?(:copy_on_write_friendly=) and
-  GC.copy_on_write_friendly = true
+GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true
 
-  before_fork do |server, worker|
-    # the following is highly recomended for Rails + "preload_app true"
-    # as there's no need for the master process to hold a connection
-    #defined?(ActiveRecord::Base) and
-    #  ActiveRecord::Base.connection.disconnect!
-
-    # The following is only recommended for memory/DB-constrained
-    # installations.  It is not needed if your system can house
-    # twice as many worker_processes as you have configured.
-    #
-    # # This allows a new master process to incrementally
-    # # phase out the old master process with SIGTTOU to avoid a
-    # # thundering herd (especially in the "preload_app false" case)
-    # # when doing a transparent upgrade.  The last worker spawned
-    # # will then kill off the old master process with a SIGQUIT.
-    # old_pid = "#{server.config[:pid]}.oldbin"
-    # if old_pid != server.pid
-    #   begin
-    #     sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
-    #     Process.kill(sig, File.read(old_pid).to_i)
-    #   rescue Errno::ENOENT, Errno::ESRCH
-    #   end
-    # end
-    #
-    # Throttle the master from forking too quickly by sleeping.  Due
-    # to the implementation of standard Unix signal handlers, this
-    # helps (but does not completely) prevent identical, repeated signals
-    # from being lost when the receiving process is busy.
-    # sleep 1
-  end
-
-  after_fork do |server, worker|
-    # per-process listener ports for debugging/admin/migrations
-    # addr = "127.0.0.1:#{9293 + worker.nr}"
-    # server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
-
-    # the following is *required* for Rails + "preload_app true",
-    #defined?(ActiveRecord::Base) and
-    #  ActiveRecord::Base.establish_connection
-
-    # if preload_app is true, then you may also want to check and
-    # restart any other shared sockets/descriptors such as Memcached,
-    # and Redis.  TokyoCabinet file handles are safe to reuse
-    # between any number of forked children (assuming your kernel
-    # correctly implements pread()/pwrite() system calls)
-  end
+before_fork { |server, worker| }
+after_fork { |server, worker| }

+ 42 - 14
frameworks/Ruby/sinatra/hello_world.rb

@@ -1,22 +1,22 @@
-require "sinatra"
-require "sinatra/json"
-require "sinatra/activerecord"
+require 'active_record'
+Bundler.require :default
 
 set :logging, false
+ActiveRecord::Base.logger = nil
 set :activerecord_logger, nil
 set :static, false
+set :template_engine, :slim
 
 # Specify the encoder - otherwise, sinatra/json inefficiently
 # attempts to load one of several on each request
 set :json_encoder => :to_json
+
 # Don't prefix JSON results with { "world": {...} }
 ActiveRecord::Base.include_root_in_json = false
 
-if RUBY_PLATFORM == 'java'
-  set :database, { :adapter => 'jdbcmysql', :database => 'hello_world', :username => 'benchmarkdbuser', :password => 'benchmarkdbpass', :host => 'localhost', :pool => 256, :timeout => 5000 }
-else
-  set :database, { :adapter => 'mysql2', :database => 'hello_world', :username => 'benchmarkdbuser', :password => 'benchmarkdbpass', :host => 'localhost', :pool => 256, :timeout => 5000 }
-end
+db_config = { :database => 'hello_world', :username => 'benchmarkdbuser', :password => 'benchmarkdbpass', :pool => 256, :timeout => 5000 }
+adapter = RUBY_PLATFORM == 'java' ? 'jdbcmysql' : 'mysql2'
+set :database, db_config.merge(:adapter => adapter, :host => ENV['DB_HOST'])
 
 # The sinatra-activerecord gem registers before and after filters that
 # call expensive synchronized ActiveRecord methods on every request to
@@ -29,7 +29,10 @@ settings.filters[:after].clear
 
 class World < ActiveRecord::Base
   self.table_name = "World"
-  attr_accessible :randomNumber
+end
+
+class Fortune < ActiveRecord::Base
+  self.table_name = "Fortune"
 end
 
 get '/json' do
@@ -42,9 +45,10 @@ get '/plaintext' do
 end
 
 get '/db' do
-  ActiveRecord::Base.connection_pool.with_connection do
-    json(World.find(Random.rand(10000) + 1))
+  worlds = ActiveRecord::Base.connection_pool.with_connection do
+    World.find(Random.rand(10000) + 1)
   end
+  json(worlds)
 end
 
 get '/queries' do
@@ -52,11 +56,35 @@ get '/queries' do
   queries = 1 if queries < 1
   queries = 500 if queries > 500
 
-  ActiveRecord::Base.connection_pool.with_connection do
-    results = (1..queries).map do
+  worlds = ActiveRecord::Base.connection_pool.with_connection do
+    (1..queries).map do
       World.find(Random.rand(10000) + 1)
     end
+  end
+  json(worlds)
+end
+
+get '/fortunes' do
+  @fortunes = Fortune.all
+  @fortunes << Fortune.new(:id => 0, :message => "Additional fortune added at request time.")
+  @fortunes = @fortunes.sort_by { |x| x.message }
 
-    json(results)
+  slim :fortunes
+end
+
+get '/updates' do
+  queries = (params[:queries] || 1).to_i
+  queries = 1 if queries < 1
+  queries = 500 if queries > 500
+
+  worlds = ActiveRecord::Base.connection_pool.with_connection do
+    worlds = (1..queries).map do
+      world = World.find(Random.rand(10000) + 1)
+      world.randomNumber = Random.rand(10000) + 1
+      world
+    end
+    World.import worlds, :on_duplicate_key_update => [:randomNumber]
+    worlds
   end
+  json(worlds)
 end

+ 32 - 0
frameworks/Ruby/sinatra/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/sinatra/install.sh

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

+ 16 - 0
frameworks/Ruby/sinatra/run_jruby_puma.py

@@ -0,0 +1,16 @@
+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.8 do bundle exec puma -C config/puma.rb"
+
+  commands = [
+    Command("rvm jruby-1.7.8 do bundle --jobs 4", True),
+    Command(start_server, False)
+  ]
+
+  return helper.run(commands, logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('puma', logfile, errfile)

+ 16 - 0
frameworks/Ruby/sinatra/run_mri_puma.py

@@ -0,0 +1,16 @@
+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.0.0-p0 do bundle exec puma -C config/puma.rb -w 8 --preload"
+
+  commands = [
+    Command("rvm ruby-2.0.0-p0 do bundle --jobs 4", True),
+    Command(start_server, False)
+  ]
+
+  return helper.run(commands, logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('puma', logfile, errfile)

+ 19 - 0
frameworks/Ruby/sinatra/run_thin.py

@@ -0,0 +1,19 @@
+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.0.0-p0 do bundle exec thin start -C config/thin.yml"
+
+  commands = [
+    Command("rvm ruby-2.0.0-p0 do bundle --jobs 4", True),
+    Command(start_server, False)
+  ]
+
+  return helper.run(commands, 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)

+ 16 - 0
frameworks/Ruby/sinatra/run_torqbox.py

@@ -0,0 +1,16 @@
+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.8 do bundle exec torqbox -b 0.0.0.0 -E production"
+
+  commands = [
+    Command("rvm jruby-1.7.8 do bundle --jobs 4", True),
+    Command(start_server, False)
+  ]
+
+  return helper.run(commands, logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('torqbox', logfile, errfile)

+ 16 - 0
frameworks/Ruby/sinatra/run_trinidad.py

@@ -0,0 +1,16 @@
+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.8 do bundle exec trinidad --config config/trinidad.yml"
+
+  commands = [
+    Command("rvm jruby-1.7.8 do bundle --jobs 4", True),
+    Command(start_server, False)
+  ]
+
+  return helper.run(commands, logfile, errfile, args.troot)
+
+def stop(logfile, errfile):
+  return helper.stop('trinidad', logfile, errfile)

+ 23 - 0
frameworks/Ruby/sinatra/run_unicorn.py

@@ -0,0 +1,23 @@
+import os
+import setup_util
+
+import helper
+from helper import Command
+
+def start(args, logfile, errfile):
+  #setup_util.replace_text("sinatra/config/nginx.conf", "/path/to/app/current", args.troot)
+
+  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
+  start_server = db_host + " rvm ruby-2.0.0-p0 do bundle exec unicorn -E production -c config/unicorn.rb"
+
+  commands = [
+    Command("rvm ruby-2.0.0-p0 do bundle --jobs 4", True),
+    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 - 27
frameworks/Ruby/sinatra/setup_jruby.py

@@ -1,27 +0,0 @@
-import subprocess
-import sys
-import os
-import setup_util
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("sinatra/hello_world.rb", ":host => '.*'", ":host => '" + args.database_host + "'")
-  try:
-    subprocess.check_call("cp Gemfile-jruby Gemfile", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
-    subprocess.check_call("cp Gemfile-jruby.lock Gemfile.lock", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
-    subprocess.Popen("rvm jruby-1.7.8 do bundle exec torqbox -b 0.0.0.0 -E production", shell=True, cwd="sinatra", 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 Gemfile", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
-    subprocess.check_call("rm Gemfile.lock", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1

+ 0 - 32
frameworks/Ruby/sinatra/setup_ruby.py

@@ -1,32 +0,0 @@
-
-import subprocess
-import sys
-import re
-import os
-import setup_util
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("sinatra/hello_world.rb", ":host => '.*'", ":host => '" + args.database_host + "'")
-  setup_util.replace_text("sinatra/config/nginx.conf", "/path/to/app/current", args.troot)
-  try:
-    subprocess.check_call("cp Gemfile-ruby Gemfile", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
-    subprocess.check_call("cp Gemfile-ruby.lock Gemfile.lock", shell=True, cwd="sinatra", 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 ruby-2.0.0-p0 do bundle exec unicorn_rails -E production -c $TROOT/config/unicorn.rb", shell=True, cwd="sinatra", 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 Gemfile", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
-    subprocess.check_call("rm Gemfile.lock", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1

+ 1 - 1
frameworks/Ruby/sinatra/source_code

@@ -1 +1 @@
-./sinatra/hello_world.rb
+./hello_world.rb

+ 9 - 0
frameworks/Ruby/sinatra/views/fortunes.slim

@@ -0,0 +1,9 @@
+== slim :layout
+  table
+    tr
+      th id
+      th message
+    - for fortune in @fortunes
+      tr
+        td =fortune.id
+        td =fortune.message

+ 6 - 0
frameworks/Ruby/sinatra/views/layout.slim

@@ -0,0 +1,6 @@
+doctype html
+html
+  head
+    title Fortunes
+  body
+    == yield