Browse Source

Merge pull request #1312 from TechEmpower/replace-setup-scala-play2

Replace Python Setup Files For Play2 Scala
Mike Smith 10 years ago
parent
commit
e492aa2618

+ 0 - 58
frameworks/Scala/play2-scala/setup_common.py

@@ -1,58 +0,0 @@
-# This file and frameworks/Java/play2-java/setup_common.py are
-# duplicates and should be kept in sync.
-
-import os, setup_util, signal, subprocess
-
-# Create start and stop functions for the Play project with the given dir
-# and install them in the given module's globals.
-def make_setup_for_dir(module_globals, subtest_name):
-
-  def start(args, logfile, errfile):
-    kill_running_process(logfile)
-
-    subtest_dir = get_subtest_dir()
-    install_dir = os.environ['IROOT']
-
-    is_windows = os.name == "nt"
-    cmd_suffix = '.bat' if is_windows else ''
-    sbt_cmd = os.path.join(install_dir, 'sbt', 'bin', 'sbt'+cmd_suffix)
-    app_cmd = os.path.join(subtest_dir, 'target','universal','stage','bin',subtest_name+cmd_suffix)
-
-    setup_util.replace_text(
-      os.path.join(subtest_dir,'conf','application.conf'),
-      "jdbc:mysql:\/\/.*:3306", "jdbc:mysql://" + args.database_host + ":3306")
-    logfile.write('Staging app: '+sbt_cmd+' stage\n')
-    subprocess.call(
-      [sbt_cmd, 'stage'],
-      stdin=subprocess.PIPE, cwd=subtest_dir, stderr=errfile, stdout=logfile)
-    logfile.write('Starting app: '+app_cmd+'\n')
-    subprocess.Popen(
-      [app_cmd],
-      shell=True, stdin=subprocess.PIPE, cwd=subtest_dir, stderr=errfile, stdout=logfile)
-    return 0
-
-  def stop(logfile, errfile):
-    kill_running_process(logfile)  
-    return 0
-
-  # Install the start and stop functions in the calling module
-  module_globals['start'] = start
-  module_globals['stop'] = stop
-
-  def get_subtest_dir():
-    test_dir = os.environ['TROOT']
-    return os.path.join(test_dir, subtest_name)
-
-  # Kill the running process and delete the RUNNING_PID file (if any).
-  def kill_running_process(logfile):
-    subtest_dir = get_subtest_dir()
-    pidfile = os.path.join(subtest_dir,"target","universal","stage","RUNNING_PID")
-    if not os.path.exists(pidfile):
-      logfile.write('No PID file: {}\n'.format(pidfile))
-      return
-    logfile.write('Reading and deleting PID file: {}\n'.format(pidfile))
-    with open(pidfile) as f:
-      pid = int(f.read())
-    os.remove(pidfile)
-    logfile.write('Sending SIGTERM to process: {}\n'.format(pid))
-    os.kill(pid, signal.SIGTERM)

+ 0 - 6
frameworks/Scala/play2-scala/setup_scala.py

@@ -1,6 +0,0 @@
-
-# This file was generated by frameworks/Java/play2-java/generate_config.py.
-# Do not edit this file directly, use the script to regenerate.
-from .setup_common import make_setup_for_dir
-
-make_setup_for_dir(globals(), 'play2-scala')

+ 16 - 0
frameworks/Scala/play2-scala/setup_scala.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+cd play2-scala
+sed -i "s|jdbc:mysql:\/\/.*:3306|jdbc:mysql://${DBHOST}:3306|g" conf/application.conf
+
+# If application is running, clear old running app.
+if [ -f ${TROOT}/play2-scala/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-scala/target/universal/stage/RUNNING_PID
+fi
+
+# Stage application.
+${IROOT}/sbt/bin/sbt stage
+
+# Execute Start script in background.
+${TROOT}/play2-scala/target/universal/stage/bin/play2-scala &

+ 0 - 6
frameworks/Scala/play2-scala/setup_scala_anorm.py

@@ -1,6 +0,0 @@
-
-# This file was generated by frameworks/Java/play2-java/generate_config.py.
-# Do not edit this file directly, use the script to regenerate.
-from .setup_common import make_setup_for_dir
-
-make_setup_for_dir(globals(), 'play2-scala-anorm')

+ 16 - 0
frameworks/Scala/play2-scala/setup_scala_anorm.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+cd play2-scala-anorm
+sed -i "s|jdbc:mysql:\/\/.*:3306|jdbc:mysql://${DBHOST}:3306|g" conf/application.conf
+
+# If application has an already existing process id, clear it.
+if [ -f ${TROOT}/play2-scala-anorm/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-scala-anorm/target/universal/stage/RUNNING_PID
+fi
+
+# Stage application.
+${IROOT}/sbt/bin/sbt stage
+
+# Execute Start script in background.
+${TROOT}/play2-scala-anorm/target/universal/stage/bin/play2-scala-anorm &

+ 0 - 6
frameworks/Scala/play2-scala/setup_scala_slick.py

@@ -1,6 +0,0 @@
-
-# This file was generated by frameworks/Java/play2-java/generate_config.py.
-# Do not edit this file directly, use the script to regenerate.
-from .setup_common import make_setup_for_dir
-
-make_setup_for_dir(globals(), 'play2-scala-slick')

+ 16 - 0
frameworks/Scala/play2-scala/setup_scala_slick.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+cd play2-scala-slick
+sed -i "s|jdbc:mysql:\/\/.*:3306|jdbc:mysql://${DBHOST}:3306|g" conf/application.conf
+
+# If application is running, clear old running app.
+if [ -f ${TROOT}/play2-scala-slick/target/universal/stage/RUNNING_PID ]
+then
+  rm -f -r ${TROOT}/play2-scala-slick/target/universal/stage/RUNNING_PID
+fi
+
+# Stage application.
+${IROOT}/sbt/bin/sbt stage
+
+# Execute Start script in background.
+${TROOT}/play2-scala-slick/target/universal/stage/bin/play2-scala-slick &