Browse Source

Convert setup.py to setup.sh for web-simple

Lita Gratrix 10 years ago
parent
commit
94f196ff74

+ 1 - 1
frameworks/Perl/web-simple/bash_profile.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
 #!/bin/bash
 
 
 export PERL_HOME=${IROOT}/perl-5.18
 export PERL_HOME=${IROOT}/perl-5.18
+export NGINX_HOME=${IROOT}/nginx
 
 
-export PATH="$PERL_HOME/bin:$PATH"

+ 0 - 30
frameworks/Perl/web-simple/setup.py

@@ -1,30 +0,0 @@
-import subprocess
-import sys
-import setup_util
-from os.path import expanduser
-import os
-import getpass
-
-def start(args, logfile, errfile):
-  setup_util.replace_text("web-simple/app.pl", "localhost", args.database_host)
-  setup_util.replace_text("web-simple/nginx.conf", "USR", getpass.getuser())
-  setup_util.replace_text("web-simple/nginx.conf", "server unix:.*\/FrameworkBenchmarks/web-simple", "server unix:" + args.troot)
-
-  try:
-    subprocess.Popen("plackup -E production -s Starman --workers=" + str(args.max_threads) + " -l $TROOT/frameworks-benchmark.sock -a $TROOT/app.pl", shell=True, cwd="web-simple", stderr=errfile, stdout=logfile)
-    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c $TROOT/nginx.conf", shell=True, stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-def stop(logfile, errfile):
-  try:
-    subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True, stderr=errfile, stdout=logfile)
-    p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-    out, err = p.communicate()
-    for line in out.splitlines():
-      if 'starman' in line:
-        pid = int(line.split(None, 2)[1])
-        os.kill(pid, 15)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1

+ 9 - 0
frameworks/Perl/web-simple/setup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+sed -i 's|localhost|'"${DBHOST}"'|g' app.pl
+sed -i 's|server unix:.*/FrameworkBenchmarks/web-simple|server unix:'"${TROOT}"'|g' nginx.conf
+
+export PATH="$PERL_HOME/bin:$PATH"
+
+plackup -E production -s Starman --workers=${MAX_THREADS} -l $TROOT/frameworks-benchmark.sock -a $TROOT/app.pl &
+$NGINX_HOME/sbin/nginx -c $TROOT/nginx.conf