Browse Source

Updated the Ruby frameworks

Mike Smith 10 years ago
parent
commit
2b66fe9ade
61 changed files with 231 additions and 561 deletions
  1. 0 32
      frameworks/Ruby/padrino/helper.py
  2. 0 10
      frameworks/Ruby/padrino/run_jruby_puma.py
  3. 0 10
      frameworks/Ruby/padrino/run_mri_puma.py
  4. 0 10
      frameworks/Ruby/padrino/run_rbx_puma.py
  5. 0 13
      frameworks/Ruby/padrino/run_thin.py
  6. 0 10
      frameworks/Ruby/padrino/run_torqbox.py
  7. 0 10
      frameworks/Ruby/padrino/run_trinidad.py
  8. 0 16
      frameworks/Ruby/padrino/run_unicorn.py
  9. 1 4
      frameworks/Ruby/rack/bash_profile.sh
  10. 0 32
      frameworks/Ruby/rack/helper.py
  11. 0 10
      frameworks/Ruby/rack/run_jruby_puma.py
  12. 10 0
      frameworks/Ruby/rack/run_jruby_puma.sh
  13. 0 10
      frameworks/Ruby/rack/run_mri_puma.py
  14. 10 0
      frameworks/Ruby/rack/run_mri_puma.sh
  15. 0 10
      frameworks/Ruby/rack/run_rbx_puma.py
  16. 10 0
      frameworks/Ruby/rack/run_rbx_puma.sh
  17. 0 12
      frameworks/Ruby/rack/run_thin.py
  18. 10 0
      frameworks/Ruby/rack/run_thin.sh
  19. 0 10
      frameworks/Ruby/rack/run_torqbox.py
  20. 10 0
      frameworks/Ruby/rack/run_torqbox.sh
  21. 0 10
      frameworks/Ruby/rack/run_trinidad.py
  22. 10 0
      frameworks/Ruby/rack/run_trinidad.sh
  23. 0 16
      frameworks/Ruby/rack/run_unicorn.py
  24. 12 0
      frameworks/Ruby/rack/run_unicorn.sh
  25. 0 5
      frameworks/Ruby/rails-stripped/bash_profile.sh
  26. 0 29
      frameworks/Ruby/rails-stripped/setup_jruby.py
  27. 14 0
      frameworks/Ruby/rails-stripped/setup_jruby.sh
  28. 0 31
      frameworks/Ruby/rails-stripped/setup_ruby.py
  29. 14 0
      frameworks/Ruby/rails-stripped/setup_ruby.sh
  30. 1 4
      frameworks/Ruby/rails/bash_profile.sh
  31. 0 32
      frameworks/Ruby/rails/helper.py
  32. 0 10
      frameworks/Ruby/rails/run_jruby_puma.py
  33. 8 0
      frameworks/Ruby/rails/run_jruby_puma.sh
  34. 0 10
      frameworks/Ruby/rails/run_mri_puma.py
  35. 8 0
      frameworks/Ruby/rails/run_mri_puma.sh
  36. 0 10
      frameworks/Ruby/rails/run_rbx_puma.py
  37. 8 0
      frameworks/Ruby/rails/run_rbx_puma.sh
  38. 0 13
      frameworks/Ruby/rails/run_thin.py
  39. 8 0
      frameworks/Ruby/rails/run_thin.sh
  40. 0 10
      frameworks/Ruby/rails/run_torqbox.py
  41. 8 0
      frameworks/Ruby/rails/run_torqbox.sh
  42. 0 10
      frameworks/Ruby/rails/run_trinidad.py
  43. 8 0
      frameworks/Ruby/rails/run_trinidad.sh
  44. 0 20
      frameworks/Ruby/rails/run_unicorn.py
  45. 10 0
      frameworks/Ruby/rails/run_unicorn.sh
  46. 1 4
      frameworks/Ruby/sinatra/bash_profile.sh
  47. 0 32
      frameworks/Ruby/sinatra/helper.py
  48. 0 16
      frameworks/Ruby/sinatra/run_jruby_puma.py
  49. 10 0
      frameworks/Ruby/sinatra/run_jruby_puma.sh
  50. 0 16
      frameworks/Ruby/sinatra/run_mri_puma.py
  51. 10 0
      frameworks/Ruby/sinatra/run_mri_puma.sh
  52. 0 10
      frameworks/Ruby/sinatra/run_rbx_puma.py
  53. 8 0
      frameworks/Ruby/sinatra/run_rbx_puma.sh
  54. 0 19
      frameworks/Ruby/sinatra/run_thin.py
  55. 10 0
      frameworks/Ruby/sinatra/run_thin.sh
  56. 0 16
      frameworks/Ruby/sinatra/run_torqbox.py
  57. 10 0
      frameworks/Ruby/sinatra/run_torqbox.sh
  58. 0 16
      frameworks/Ruby/sinatra/run_trinidad.py
  59. 10 0
      frameworks/Ruby/sinatra/run_trinidad.sh
  60. 0 23
      frameworks/Ruby/sinatra/run_unicorn.py
  61. 12 0
      frameworks/Ruby/sinatra/run_unicorn.sh

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

@@ -1,32 +0,0 @@
-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

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

@@ -1,10 +0,0 @@
-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"
-  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('puma', logfile, errfile)

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

@@ -1,10 +0,0 @@
-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"
-  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('puma', logfile, errfile)

+ 0 - 10
frameworks/Ruby/padrino/run_rbx_puma.py

@@ -1,10 +0,0 @@
-import helper
-from helper import Command
-
-def start(args, logfile, errfile):
-  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
-  command = Command(db_host + " rvm rbx-2.2.10 do bundle exec puma", False)
-  return helper.run([command], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('puma', logfile, errfile)

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

@@ -1,13 +0,0 @@
-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"
-  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)

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

@@ -1,10 +0,0 @@
-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"
-  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('torqbox', logfile, errfile)

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

@@ -1,10 +0,0 @@
-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"
-  return helper.run([Command(start_server, False)], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('trinidad', logfile, errfile)

+ 0 - 16
frameworks/Ruby/padrino/run_unicorn.py

@@ -1,16 +0,0 @@
-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 unicorn -E production -c 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):
-  command = Command("sudo /usr/local/nginx/sbin/nginx -c $TROOT/config/nginx.conf -s stop ", True)
-  helper.run([command], logfile, errfile, os.environ['TROOT'])
-  return helper.stop('unicorn', logfile, errfile)

+ 1 - 4
frameworks/Ruby/rack/bash_profile.sh

@@ -2,8 +2,5 @@
 
 export LC_ALL=en_US.UTF-8 
 export LANG=en_US.UTF-8
-# We assume single-user installation as 
-# done in our rvm.sh script and 
-# in Travis-CI
-source $HOME/.rvm/scripts/rvm
 
+export NGINX_HOME=${IROOT}/nginx

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

@@ -1,32 +0,0 @@
-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

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

@@ -1,10 +0,0 @@
-import helper
-from helper import Command
-
-def start(args, logfile, errfile):
-  helper.set_database_host(args)
-  command = Command("rvm jruby-1.7.8 do bundle exec puma -b tcp://0.0.0.0:8080 -e production", False)
-  return helper.run([command], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('puma', logfile, errfile)

+ 10 - 0
frameworks/Ruby/rack/run_jruby_puma.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+sed -i 's|  host:.*|  host:'"${DBHOST}"'|g' config/database.yml
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm jruby-1.7.8 do bundle exec puma -b tcp://0.0.0.0:8080 -e production &

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

@@ -1,10 +0,0 @@
-import helper
-from helper import Command
-
-def start(args, logfile, errfile):
-  helper.set_database_host(args)
-  command = Command("rvm ruby-2.0.0-p0 do bundle exec puma -t 8:32 -w 8 --preload -b tcp://0.0.0.0:8080 -e production", False)
-  return helper.run([command], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('puma', logfile, errfile)

+ 10 - 0
frameworks/Ruby/rack/run_mri_puma.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+sed -i 's|  host:.*|  host:'"${DBHOST}"'|g' config/database.yml
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm ruby-2.0.0-p0 do bundle exec puma -t 8:32 -w 8 --preload -b tcp://0.0.0.0:8080 -e production &

+ 0 - 10
frameworks/Ruby/rack/run_rbx_puma.py

@@ -1,10 +0,0 @@
-import helper
-from helper import Command
-
-def start(args, logfile, errfile):
-  helper.set_database_host(args)
-  command = Command("rvm rbx-2.2.10 do bundle exec puma -b tcp://0.0.0.0:8080 -e production", False)
-  return helper.run([command], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('puma', logfile, errfile)

+ 10 - 0
frameworks/Ruby/rack/run_rbx_puma.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+sed -i 's|  host:.*|  host:'"${DBHOST}"'|g' config/database.yml
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm rbx-2.2.10 do bundle exec puma -b tcp://0.0.0.0:8080 -e production &

+ 0 - 12
frameworks/Ruby/rack/run_thin.py

@@ -1,12 +0,0 @@
-import helper
-from helper import Command
-import os
-
-def start(args, logfile, errfile):
-  helper.set_database_host(args)
-  command = Command("rvm ruby-2.0.0-p0 do bundle exec thin start -C config/thin.yml", False)
-  return helper.run([command], 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/rack/run_thin.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+sed -i 's|  host:.*|  host:'"${DBHOST}"'|g' config/database.yml
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm ruby-2.0.0-p0 do bundle exec thin start -C config/thin.yml &

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

@@ -1,10 +0,0 @@
-import helper
-from helper import Command
-
-def start(args, logfile, errfile):
-  helper.set_database_host(args)
-  command = Command("rvm jruby-1.7.8 do bundle exec torqbox -b 0.0.0.0 -E production", False)
-  return helper.run([command], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('torqbox', logfile, errfile)

+ 10 - 0
frameworks/Ruby/rack/run_torqbox.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+sed -i 's|  host:.*|  host:'"${DBHOST}"'|g' config/database.yml
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm jruby-1.7.8 do bundle exec torqbox -b 0.0.0.0 -E production &

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

@@ -1,10 +0,0 @@
-import helper
-from helper import Command
-
-def start(args, logfile, errfile):
-  helper.set_database_host(args)
-  command = Command("rvm jruby-1.7.8 do bundle exec trinidad --config config/trinidad.yml", False)
-  return helper.run([command], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('trinidad', logfile, errfile)

+ 10 - 0
frameworks/Ruby/rack/run_trinidad.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+sed -i 's|  host:.*|  host:'"${DBHOST}"'|g' config/database.yml
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm jruby-1.7.8 do bundle exec trinidad --config config/trinidad.yml &

+ 0 - 16
frameworks/Ruby/rack/run_unicorn.py

@@ -1,16 +0,0 @@
-import helper
-from helper import Command
-import os
-
-def start(args, logfile, errfile):
-  helper.set_database_host(args)
-  commands = [
-    Command("sudo /usr/local/nginx/sbin/nginx -c $TROOT/config/nginx.conf", True),
-    Command("rvm ruby-2.0.0-p0 do bundle exec unicorn -E production -c config/unicorn.rb", 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)

+ 12 - 0
frameworks/Ruby/rack/run_unicorn.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+
+sed -i 's|  host:.*|  host:'"${DBHOST}"'|g' config/database.yml
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+$NGINX_HOME/sbin/nginx -c $TROOT/config/nginx.conf
+
+rvm ruby-2.0.0-p0 do bundle exec unicorn -E production -c config/unicorn.rb &

+ 0 - 5
frameworks/Ruby/rails-stripped/bash_profile.sh

@@ -1,7 +1,2 @@
 #!/bin/bash
 
-# We assume single-user installation as 
-# done in our rvm.sh script and 
-# in Travis-CI
-source $HOME/.rvm/scripts/rvm
-

+ 0 - 29
frameworks/Ruby/rails-stripped/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-stripped/config/database.yml", "host: .*", "host: " + args.database_host)
-
-  try:
-    subprocess.check_call("cp Gemfile-jruby Gemfile", shell=True, cwd="rails-stripped", stderr=errfile, stdout=logfile)
-    subprocess.check_call("cp Gemfile-jruby.lock Gemfile.lock", shell=True, cwd="rails-stripped", 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="rails-stripped", 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="rails-stripped", stderr=errfile, stdout=logfile)
-    subprocess.check_call("rm Gemfile.lock", shell=True, cwd="rails-stripped", stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1

+ 14 - 0
frameworks/Ruby/rails-stripped/setup_jruby.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+sed -i 's|host: .*|host: '"${DBHOST}"'|g' config/database.yml
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rm -f Gemfile
+cp Gemfile-jruby Gemfile
+cp Gemfile-jruby.lock Gemfile.lock
+
+rvm jruby-1.7.8 do bundle exec torqbox -b 0.0.0.0 -E production &

+ 0 - 31
frameworks/Ruby/rails-stripped/setup_ruby.py

@@ -1,31 +0,0 @@
-
-import subprocess
-import sys
-import re
-import os
-import setup_util
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("rails-stripped/config/database.yml", "host: .*", "host: " + args.database_host)
-  try:
-    subprocess.check_call("cp Gemfile-ruby Gemfile", shell=True, cwd="rails-stripped", stderr=errfile, stdout=logfile)
-    subprocess.check_call("cp Gemfile-ruby.lock Gemfile.lock", shell=True, cwd="rails-stripped", 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="rails-stripped", 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="rails-stripped", stderr=errfile, stdout=logfile)
-    subprocess.check_call("rm Gemfile.lock", shell=True, cwd="rails-stripped", stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1

+ 14 - 0
frameworks/Ruby/rails-stripped/setup_ruby.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+sed -i 's|host: .*|host: '"${DBHOST}"'|g' config/database.yml
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rm -f Gemfile
+cp Gemfile-jruby Gemfile
+cp Gemfile-jruby.lock Gemfile.lock
+
+rvm ruby-2.0.0-p0 do bundle exec unicorn_rails -E production -c $TROOT/config/unicorn.rb &

+ 1 - 4
frameworks/Ruby/rails/bash_profile.sh

@@ -2,8 +2,5 @@
 
 export LC_ALL=en_US.UTF-8 
 export LANG=en_US.UTF-8
-# We assume single-user installation as 
-# done in our rvm.sh script and 
-# in Travis-CI
-source $HOME/.rvm/scripts/rvm
 
+export NGINX_HOME=${IROOT}/nginx

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

@@ -1,32 +0,0 @@
-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

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

@@ -1,10 +0,0 @@
-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)

+ 8 - 0
frameworks/Ruby/rails/run_jruby_puma.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+DB_HOST=${DBHOST} rvm jruby-1.7.13 do bundle exec puma -b tcp://0.0.0.0:8080 -e production &

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

@@ -1,10 +0,0 @@
-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)

+ 8 - 0
frameworks/Ruby/rails/run_mri_puma.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+DB_HOST=${DBHOST} rvm ruby-2.1.2 do bundle exec puma -t 8:32 -w 8 --preload -b tcp://0.0.0.0:8080 -e production &

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

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

+ 8 - 0
frameworks/Ruby/rails/run_rbx_puma.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+DB_HOST=${DBHOST} rvm rbx-2.2.10 do bundle exec puma -b tcp://0.0.0.0:8080 -e production &

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

@@ -1,13 +0,0 @@
-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)

+ 8 - 0
frameworks/Ruby/rails/run_thin.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+DB_HOST=${DBHOST} rvm ruby-2.1.2 do bundle exec thin start -C config/thin.yml &

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

@@ -1,10 +0,0 @@
-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)

+ 8 - 0
frameworks/Ruby/rails/run_torqbox.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+DB_HOST=${DBHOST} rvm jruby-1.7.13 do bundle exec torqbox -b 0.0.0.0 -E production &

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

@@ -1,10 +0,0 @@
-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)

+ 8 - 0
frameworks/Ruby/rails/run_trinidad.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+DB_HOST=${DBHOST} rvm jruby-1.7.13 do bundle exec trinidad --config config/trinidad.yml &

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

@@ -1,20 +0,0 @@
-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)

+ 10 - 0
frameworks/Ruby/rails/run_unicorn.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+$NGINX_HOME/sbin/nginx -c $TROOT/config/nginx.conf
+
+DB_HOST=${DBHOST} rvm 2.1.2 do bundle exec unicorn_rails -E production -c $TROOT/config/unicorn.rb &

+ 1 - 4
frameworks/Ruby/sinatra/bash_profile.sh

@@ -2,8 +2,5 @@
 
 export LC_ALL=en_US.UTF-8 
 export LANG=en_US.UTF-8
-# We assume single-user installation as 
-# done in our rvm.sh script and 
-# in Travis-CI
-source $HOME/.rvm/scripts/rvm
 
+export NGINX_HOME=${IROOT}/nginx

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

@@ -1,32 +0,0 @@
-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

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

@@ -1,16 +0,0 @@
-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)

+ 10 - 0
frameworks/Ruby/sinatra/run_jruby_puma.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm jruby-1.7.8 do bundle --jobs 4
+
+DB_HOST=${DBHOST} rvm jruby-1.7.8 do bundle exec puma -C config/puma.rb &

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

@@ -1,16 +0,0 @@
-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)

+ 10 - 0
frameworks/Ruby/sinatra/run_mri_puma.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm ruby-2.0.0-p0 do bundle --jobs 4
+
+DB_HOST=${DBHOST} rvm ruby-2.0.0-p0 do bundle exec puma -C config/puma.rb -w 8 --preload &

+ 0 - 10
frameworks/Ruby/sinatra/run_rbx_puma.py

@@ -1,10 +0,0 @@
-import helper
-from helper import Command
-
-def start(args, logfile, errfile):
-  db_host = "DB_HOST={0}".format(args.database_host or 'localhost')
-  command = Command(db_host + " rvm rbx-2.2.10 do bundle exec puma", False)
-  return helper.run([command], logfile, errfile, args.troot)
-
-def stop(logfile, errfile):
-  return helper.stop('puma', logfile, errfile)

+ 8 - 0
frameworks/Ruby/sinatra/run_rbx_puma.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+DB_HOST=${DBHOST} rvm rbx-2.2.10 do bundle exec puma &

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

@@ -1,19 +0,0 @@
-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)

+ 10 - 0
frameworks/Ruby/sinatra/run_thin.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm ruby-2.0.0-p0 do bundle --jobs 4
+
+DB_HOST=${DBHOST} rvm ruby-2.0.0-p0 do bundle exec thin start -C config/thin.yml &

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

@@ -1,16 +0,0 @@
-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)

+ 10 - 0
frameworks/Ruby/sinatra/run_torqbox.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm jruby-1.7.8 do bundle --jobs 4
+
+DB_HOST=${DBHOST} rvm jruby-1.7.8 do bundle exec torqbox -b 0.0.0.0 -E production &

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

@@ -1,16 +0,0 @@
-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)

+ 10 - 0
frameworks/Ruby/sinatra/run_trinidad.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm jruby-1.7.8 do bundle --jobs 4
+
+DB_HOST=${DBHOST} rvm jruby-1.7.8 do bundle exec trinidad --config config/trinidad.yml &

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

@@ -1,23 +0,0 @@
-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)

+ 12 - 0
frameworks/Ruby/sinatra/run_unicorn.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# We assume single-user installation as 
+# done in our rvm.sh script and 
+# in Travis-CI
+source $HOME/.rvm/scripts/rvm
+
+rvm ruby-2.0.0-p0 do bundle --jobs 4
+
+$NGINX_HOME/sbin/nginx -c $TROOT/config/nginx.conf
+
+DB_HOST=${DBHOST} rvm ruby-2.0.0-p0 do bundle exec unicorn -E production -c config/unicorn.rb &