Browse Source

Updated grape

Mike Smith 10 years ago
parent
commit
ac27365752

+ 1 - 5
frameworks/Ruby/grape/bash_profile.sh

@@ -3,8 +3,4 @@
 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/grape/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/grape/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/grape/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
+
+sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
+
+rvm jruby-1.7.8 do bundle exec puma -b tcp://0.0.0.0:8080 -e production &

+ 0 - 10
frameworks/Ruby/grape/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/grape/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
+
+sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
+
+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/grape/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/grape/run_rbx_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
+
+sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
+
+rvm rbx-2.2.10 do bundle exec puma -b tcp://0.0.0.0:8080 -e production &

+ 0 - 11
frameworks/Ruby/grape/run_thin.py

@@ -1,11 +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 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, '.')  
-  return helper.stop('thin', logfile, errfile)

+ 10 - 0
frameworks/Ruby/grape/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
+
+sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
+
+rvm ruby-2.0.0-p0 do bundle exec thin start -C config/thin.yml &

+ 0 - 10
frameworks/Ruby/grape/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/grape/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
+
+sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
+
+rvm jruby-1.7.8 do bundle exec torqbox -b 0.0.0.0 -E production &

+ 0 - 10
frameworks/Ruby/grape/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/grape/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
+
+sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
+
+rvm jruby-1.7.8 do bundle exec trinidad --config config/trinidad.yml

+ 0 - 14
frameworks/Ruby/grape/run_unicorn.py

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

+ 12 - 0
frameworks/Ruby/grape/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
+
+sed -i 's|  host:.*|  host: '"${DBHOST}"'|g' config/database.yml
+
+$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 &

+ 3 - 3
toolset/setup/linux/languages/rvm.sh

@@ -3,14 +3,14 @@
 RETCODE=$(fw_exists rvm.installed)
 [ ! "$RETCODE" == 0 ] || { \
   # Assume single-user installation
-  source $HOME/.rvm/scripts/rvm
+  source ~/.rvm/scripts/rvm
   return 0;
 }
 
 # Never run installation inside of TRAVIS, 
 # just rely on their default RVM installaton
 [ "$TRAVIS" != "true" ] || { \
-  source $HOME/.rvm/scripts/rvm
+  source ~/.rvm/scripts/rvm
   touch rvm.installed
   return 0;
 }
@@ -19,6 +19,6 @@ RETCODE=$(fw_exists rvm.installed)
 export SHELL=/bin/bash
 gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
 \curl -sSL https://get.rvm.io | bash -s stable
-source $HOME/.rvm/scripts/rvm
+source ~/.rvm/scripts/rvm
 
 touch $IROOT/rvm.installed