Browse Source

Merge pull request #1294 from hamiltont/fix-express

JavaScript: Fix express
Hamilton Turner 10 years ago
parent
commit
ca9ee21ddf

+ 12 - 1
frameworks/JavaScript/express/setup.sh

@@ -4,6 +4,17 @@ sed -i 's|mongodb://.*/hello_world|mongodb://'"${DBHOST}"'/hello_world|g' app.js
 sed -i 's|localhost|'"${DBHOST}"'|g' app.js
 
 export NODE_ENV=production
+export NODE_HOME=${IROOT}/node-v0.10.8-linux-x64
+export PATH=$PATH:$NODE_HOME/bin
 
 ${NODE_HOME}/bin/npm install
-${NODE_HOME}/bin/node app &
+${NODE_HOME}/bin/node app &
+
+# !DO NOT REMOVE!
+#
+# It takes `node app` a few seconds to turn on and 
+# then fork. If you remove this sleep, the parent shell 
+# executing this script will be terminated before the 
+# application has time to awaken and be forked, and 
+# express will fail to be started
+sleep 5

+ 1 - 3
toolset/benchmark/benchmarker.py

@@ -655,11 +655,9 @@ class Benchmarker:
 
   ############################################################
   # __stop_test(benchmarker)
-  # Stops a running test
+  # Stops all running tests
   ############################################################
   def __stop_test(self, out, err):
-
-    # Meganuke
     try:
       subprocess.check_call('sudo killall -s 9 -u %s' % self.runner_user, shell=True, stderr=err, stdout=out)
       retcode = 0

+ 26 - 5
toolset/benchmark/framework_test.py

@@ -205,13 +205,34 @@ class FrameworkTest:
       # run by the framework that need to continue (read: server has
       # started and needs to remain that way), then they should be
       # executed in the background.
+      command = 'sudo -u %s -E -H bash -e %s.sh' % (self.benchmarker.runner_user, self.setup_file)
+      
+      debug_command = '''\
+        export FWROOT=%s && \\
+        export TROOT=%s && \\
+        export IROOT=%s && \\
+        export DBHOST=%s && \\
+        export MAX_THREADS=%s && \\
+        export OUT=%s && \\
+        export ERR=%s && \\
+        cd %s && \\
+        %s''' % (self.fwroot, 
+          self.directory, 
+          self.install_root, 
+          self.database_host, 
+          self.benchmarker.threads, 
+          os.path.join(self.fwroot, out.name), 
+          os.path.join(self.fwroot, err.name),
+          self.directory,
+          command)
+      logging.info("To run framework manually, copy/paste this:\n%s", debug_command)
+
       try:
-        retcode = subprocess.check_call('sudo -u %s -E -H bash -e %s.sh' % 
-          (self.benchmarker.runner_user, self.setup_file), 
-          cwd=self.directory, shell=True, stderr=errout, stdout=out)
-        if retcode == None:
-          retcode = 0
+        subprocess.check_call(command, cwd=self.directory, 
+          shell=True, stderr=errout, stdout=out)
+        retcode = 0
       except Exception:
+        logging.exception("Failure running setup.sh")
         retcode = 1
     with open('temp', 'r') as errout:
       # Read out temp error output in its entirety

+ 6 - 0
toolset/setup/linux/languages/nodejs.sh

@@ -6,4 +6,10 @@ RETCODE=$(fw_exists ${IROOT}/node-v0.10.8.installed)
 fw_get http://nodejs.org/dist/v0.10.8/node-v0.10.8-linux-x64.tar.gz
 fw_untar node-v0.10.8-linux-x64.tar.gz
 
+# Upgrade npm to avoid https://github.com/npm/npm/issues/4984
+export NODE_HOME=${IROOT}/node-v0.10.8-linux-x64
+export PATH=$PATH:$NODE_HOME/bin
+
+${NODE_HOME}/bin/npm install -g npm
+
 touch ${IROOT}/node-v0.10.8.installed