Richard Nienaber 11 éve
szülő
commit
226600b452

+ 2 - 3
frameworks/Ruby/rack/helper.py

@@ -8,11 +8,10 @@ Command = namedtuple('Command', ['command', 'wait_for_exit'])
 
 def set_database_host(args):
   database_host = args.database_host or 'localhost'
-  database_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config/database.yml')
+  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 = os.path.basename(os.path.normpath(os.path.dirname(os.path.realpath(__file__))))
+def run(commands, logfile, errfile, cwd):
   try:
     for command in commands:      
       if command.wait_for_exit:

+ 2 - 6
frameworks/Ruby/rack/run_jruby_puma.py

@@ -3,12 +3,8 @@ from helper import Command
 
 def start(args, logfile, errfile):
   helper.set_database_host(args)
-  commands = [
-    Command("rvm jruby-1.7.8 do bundle", True),
-    Command("rvm jruby-1.7.8 do bundle exec puma -b tcp://0.0.0.0:8080 -e production", False)
-  ]
-
-  return helper.run(commands, logfile, errfile)
+  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)

+ 2 - 6
frameworks/Ruby/rack/run_mri_puma.py

@@ -3,12 +3,8 @@ from helper import Command
 
 def start(args, logfile, errfile):
   helper.set_database_host(args)
-  commands = [
-    Command("rvm ruby-2.0.0-p0 do bundle", True),
-    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(commands, logfile, errfile)
+  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)

+ 4 - 7
frameworks/Ruby/rack/run_thin.py

@@ -1,15 +1,12 @@
 import helper
 from helper import Command
+import os
 
 def start(args, logfile, errfile):
   helper.set_database_host(args)
-  commands = [
-    Command("rvm ruby-2.0.0-p0 do bundle", True),
-    Command("rvm ruby-2.0.0-p0 do bundle exec thin start -C config/thin.yml", False)
-  ]
-
-  return helper.run(commands, logfile, errfile)
+  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)  
+  helper.run([Command('rm -rf tmp/*', True)], logfile, errfile, os.environ['TROOT'])  
   return helper.stop('thin', logfile, errfile)

+ 2 - 6
frameworks/Ruby/rack/run_torqbox.py

@@ -3,12 +3,8 @@ from helper import Command
 
 def start(args, logfile, errfile):
   helper.set_database_host(args)
-  commands = [
-    Command("rvm jruby-1.7.8 do bundle", True),
-    Command("rvm jruby-1.7.8 do bundle exec torqbox -b 0.0.0.0 -E production", False)
-  ]
-
-  return helper.run(commands, logfile, errfile)
+  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)

+ 2 - 6
frameworks/Ruby/rack/run_trinidad.py

@@ -3,12 +3,8 @@ from helper import Command
 
 def start(args, logfile, errfile):
   helper.set_database_host(args)
-  commands = [
-    Command("rvm jruby-1.7.8 do bundle", True),
-    Command("rvm jruby-1.7.8 do bundle exec trinidad --config config/trinidad.yml", False)
-  ]
-
-  return helper.run(commands, logfile, errfile)
+  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)

+ 4 - 7
frameworks/Ruby/rack/run_unicorn.py

@@ -1,19 +1,16 @@
 import helper
 from helper import Command
-
-from os.path import expanduser
-home = expanduser("~")
+import os
 
 def start(args, logfile, errfile):
   helper.set_database_host(args)
   commands = [
-    Command("rvm ruby-2.0.0-p0 do bundle", True),
-    Command("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/frameworks/Ruby/rack/config/nginx.conf", True),
+    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)
+  return helper.run(commands, logfile, errfile, args.troot)
 
 def stop(logfile, errfile):
-  helper.run([Command("sudo /usr/local/nginx/sbin/nginx -s stop", True)], 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)