瀏覽代碼

Updated most of the JavaScript frameworks

msmith-techempower 10 年之前
父節點
當前提交
2a2b9c6bb3

+ 3 - 0
frameworks/JavaScript/express/bash_profile.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+export NODE_HOME=${IROOT}/node-v0.10.8-linux-x64

+ 0 - 49
frameworks/JavaScript/express/setup.py

@@ -1,49 +0,0 @@
-
-import subprocess
-import sys
-import setup_util
-import os
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("express/app.js", "mongodb:\/\/.*\/hello_world", "mongodb://" + args.database_host + "/hello_world")
-  setup_util.replace_text("express/app.js", "localhost", args.database_host)
-
-  try:
-    npm(logfile,errfile)
-    if os.name == 'nt':
-      subprocess.Popen("set NODE_ENV=production", shell=True, stderr=errfile, stdout=logfile)
-      subprocess.Popen("node app", shell=True, cwd="express", stderr=errfile, stdout=logfile)
-    else:
-      subprocess.Popen("NODE_ENV=production node app", shell=True, cwd="express", stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-
-def npm(logfile, errfile):
-  if os.name == 'nt':
-    subprocess.check_call("copy package.json package.json.dist /y > NUL", shell=True, cwd="express", stderr=errfile, stdout=logfile)
-    setup_util.replace_text("express/package.json", ".*mysql.*", "")
-    setup_util.replace_text("express/package.json", ".*mapper.*", "")
-  
-  try:
-    subprocess.check_call("npm install", shell=True, cwd="express", stderr=errfile, stdout=logfile)
-  finally:
-    if os.name == 'nt':
-      subprocess.check_call("del package.json", shell=True, cwd="express", stderr=errfile, stdout=logfile)
-      subprocess.check_call("ren package.json.dist package.json", shell=True, cwd="express", stderr=errfile, stdout=logfile)
-
-def stop(logfile, errfile):
-  if os.name == 'nt':
-    subprocess.Popen("taskkill /f /im node.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
-    return 0
-  
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'node app' in line:
-      pid = int(line.split(None, 2)[1])
-      try:
-        os.kill(pid, 15)
-      except OSError:
-        pass
-  return 0

+ 9 - 0
frameworks/JavaScript/express/setup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+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
+
+${NODE_HOME}/bin/npm install
+${NODE_HOME}/bin/node app &

+ 3 - 0
frameworks/JavaScript/hapi/bash_profile.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+export NODE_HOME=${IROOT}/node-v0.10.8-linux-x64

+ 0 - 46
frameworks/JavaScript/hapi/setup.py

@@ -1,46 +0,0 @@
-import subprocess
-import sys
-import setup_util
-import os
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("hapi/app.js", "localhost", args.database_host)
-
-  try:
-    npm(logfile, errfile)
-    if os.name == 'nt':
-      subprocess.Popen("set NODE_ENV=production", shell=True, stderr=errfile, stdout=logfile)
-      subprocess.Popen("node app", shell=True, cwd="hapi", stderr=errfile, stdout=logfile)
-    else:
-      subprocess.Popen("NODE_ENV=production node app", shell=True, cwd="hapi", stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-
-def npm(logfile, errfile):
-  if os.name == 'nt':
-    subprocess.check_call("copy package.json package.json.dist /y > NUL", shell=True, cwd="hapi", stderr=errfile, stdout=logfile)
-    setup_util.replace_text("hapi/package.json", ".*mapper.*", "")
-
-  try:
-    subprocess.check_call("npm install", shell=True, cwd="hapi", stderr=errfile, stdout=logfile)
-  finally:
-    if os.name == 'nt':
-      subprocess.check_call("del package.json", shell=True, cwd="hapi", stderr=errfile, stdout=logfile)
-      subprocess.check_call("ren package.json.dist package.json", shell=True, cwd="hapi", stderr=errfile, stdout=logfile)
-
-def stop(logfile, errfile):
-  if os.name == 'nt':
-    subprocess.Popen("taskkill /f /im node.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
-    return 0
-
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'node app' in line:
-      pid = int(line.split(None, 2)[1])
-      try:
-        os.kill(pid, 15)
-      except OSError:
-        pass
-  return 0

+ 8 - 0
frameworks/JavaScript/hapi/setup.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+sed -i 's|localhost|'"${DBHOST}"'|g' app.js
+
+export NODE_ENV=production
+
+${NODE_HOME}/bin/npm install
+${NODE_HOME}/bin/node app &

+ 3 - 0
frameworks/JavaScript/nodejs/bash_profile.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+export NODE_HOME=${IROOT}/node-v0.10.8-linux-x64

+ 0 - 45
frameworks/JavaScript/nodejs/setup.py

@@ -1,45 +0,0 @@
-
-import subprocess
-import sys
-import setup_util
-import os
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("nodejs/hello.js", "mongodb:\/\/.*\/hello_world", "mongodb://" + args.database_host + "/hello_world")
-  setup_util.replace_text("nodejs/hello.js", "localhost", args.database_host)
-
-  try:
-    npm(logfile, errfile)
-    subprocess.Popen("node hello.js", shell=True, cwd="nodejs", stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-
-def npm(logfile, errfile):
-  if os.name == 'nt':
-    subprocess.check_call("copy package.json package.json.dist /y > NUL", shell=True, cwd="nodejs", stderr=errfile, stdout=logfile)
-    setup_util.replace_text("nodejs/package.json", ".*mysql.*", "")
-    setup_util.replace_text("nodejs/package.json", ".*mapper.*", "")
-  
-  try:
-    subprocess.check_call("npm install", shell=True, cwd="nodejs", stderr=errfile, stdout=logfile)
-  finally:
-    if os.name == 'nt':
-      subprocess.check_call("del package.json", shell=True, cwd="nodejs")
-      subprocess.check_call("ren package.json.dist package.json", shell=True, cwd="nodejs", stderr=errfile, stdout=logfile)
-
-def stop(logfile, errfile):
-  if os.name == 'nt':
-    subprocess.Popen("taskkill /f /im node.exe > NUL", shell=True, stderr=errfile, stdout=logfile)
-    return 0
-  
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'hello.js' in line:
-      pid = int(line.split(None, 2)[1])
-      try:
-        os.kill(pid, 15)
-      except OSError:
-        pass
-  return 0

+ 9 - 0
frameworks/JavaScript/nodejs/setup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+sed -i 's|localhost|'"${DBHOST}"'|g' hello.js
+sed -i 's|mongodb//.*/hello_world|mongodb//'"${DBHOST}"'/hello_world|g' hello.js
+
+export NODE_ENV=production
+
+${NODE_HOME}/bin/npm install
+${NODE_HOME}/bin/node hello.js &

+ 4 - 2
toolset/setup/linux/languages/nodejs.sh

@@ -1,7 +1,9 @@
 #!/bin/bash
 
-RETCODE=$(fw_exists node-v0.10.8-linux-x64)
+RETCODE=$(fw_exists ${IROOT}/node-v0.10.8.installed)
 [ ! "$RETCODE" == 0 ] || { return 0; }
 
 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
+fw_untar node-v0.10.8-linux-x64.tar.gz
+
+touch ${IROOT}/node-v0.10.8.installed

+ 2 - 2
toolset/setup/linux/languages/ringojs.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-RETCODE=$(fw_exists ringo.installed)
+RETCODE=$(fw_exists ${IROOT}/ringojs_0.10.installed)
 [ ! "$RETCODE" == 0 ] || { return 0; }
 
 fw_get http://www.ringojs.org/downloads/ringojs_0.10-1_all.deb
@@ -9,4 +9,4 @@ sudo dpkg -i ringojs_0.10-1_all.deb
 
 rm -f ringojs_0.10-1_all.deb
 
-touch $IROOT/ringo.installed
+touch $IROOT/ringojs_0.10.installed