Browse Source

Cleanup sinatra

Hamilton Turner 11 years ago
parent
commit
8233b96fde

+ 7 - 0
frameworks/Ruby/sinatra/bash_profile.sh

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

+ 1 - 1
frameworks/Ruby/sinatra/config/nginx.conf

@@ -24,7 +24,7 @@ worker_processes 8;
 #user nobody nobody; # for systems with "nobody" as a group instead
 #user nobody nobody; # for systems with "nobody" as a group instead
 
 
 # Feel free to change all paths to suite your needs here, of course
 # Feel free to change all paths to suite your needs here, of course
-# pid /tmp/nginx.pid;
+pid /tmp/nginx.pid;
 #error_log /tmp/nginx.error.log;
 #error_log /tmp/nginx.error.log;
 error_log /dev/null error;
 error_log /dev/null error;
 
 

+ 7 - 1
frameworks/Ruby/sinatra/install.sh

@@ -1,3 +1,9 @@
 #!/bin/bash
 #!/bin/bash
 
 
-fw_depends ruby
+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 install jruby-1.7.8
+rvm jruby-1.7.8 do bundle install --gemfile=$TROOT/Gemfile-jruby

+ 0 - 2
frameworks/Ruby/sinatra/setup_jruby.py

@@ -1,4 +1,3 @@
-
 import subprocess
 import subprocess
 import sys
 import sys
 import os
 import os
@@ -7,7 +6,6 @@ import setup_util
 def start(args, logfile, errfile):
 def start(args, logfile, errfile):
   setup_util.replace_text("sinatra/hello_world.rb", ":host => '.*'", ":host => '" + args.database_host + "'")
   setup_util.replace_text("sinatra/hello_world.rb", ":host => '.*'", ":host => '" + args.database_host + "'")
   try:
   try:
-    subprocess.check_call("rvm jruby-1.7.8 do bundle install --gemfile=Gemfile-jruby", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
     subprocess.check_call("cp Gemfile-jruby Gemfile", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
     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.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)
     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)

+ 4 - 9
frameworks/Ruby/sinatra/setup_ruby.py

@@ -4,24 +4,20 @@ import sys
 import re
 import re
 import os
 import os
 import setup_util
 import setup_util
-from os.path import expanduser
-
-home = expanduser("~")
 
 
 def start(args, logfile, errfile):
 def start(args, logfile, errfile):
   setup_util.replace_text("sinatra/hello_world.rb", ":host => '.*'", ":host => '" + args.database_host + "'")
   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", home + "/FrameworkBenchmarks/sinatra")
+  setup_util.replace_text("sinatra/config/nginx.conf", "/path/to/app/current", args.troot)
   try:
   try:
-    subprocess.check_call("rvm ruby-2.0.0-p0 do bundle install --gemfile=Gemfile-ruby", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
     subprocess.check_call("cp Gemfile-ruby Gemfile", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
     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("cp Gemfile-ruby.lock Gemfile.lock", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
-    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/sinatra/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 config/unicorn.rb", 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
     return 0
   except subprocess.CalledProcessError:
   except subprocess.CalledProcessError:
     return 1
     return 1
 def stop(logfile, errfile):
 def stop(logfile, errfile):
-  subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True, stderr=errfile, stdout=logfile)
+  subprocess.call("sudo /usr/local/nginx/sbin/nginx -c $TROOT/config/nginx.conf -s stop", shell=True, stderr=errfile, stdout=logfile)
   try:
   try:
     p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
     p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
     out, err = p.communicate()
     out, err = p.communicate()
@@ -29,7 +25,6 @@ def stop(logfile, errfile):
       if 'unicorn' in line and 'master' in line:
       if 'unicorn' in line and 'master' in line:
         pid = int(line.split(None, 2)[1])
         pid = int(line.split(None, 2)[1])
         os.kill(pid, 15)
         os.kill(pid, 15)
-    # subprocess.check_call("rvm ruby-2.0.0-p0 do bundle exec passenger stop --pid-file=$HOME/FrameworkBenchmarks/rack/rack.pid", shell=True, cwd='rack')
     subprocess.check_call("rm Gemfile", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
     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)
     subprocess.check_call("rm Gemfile.lock", shell=True, cwd="sinatra", stderr=errfile, stdout=logfile)
     return 0
     return 0