Browse Source

remove hard-coding of paths in perl frameworks

Joel Berger 11 years ago
parent
commit
0ab1fdf974
10 changed files with 26 additions and 41 deletions
  1. 1 1
      dancer/install.sh
  2. 4 6
      dancer/setup.py
  3. 1 1
      kelp/install.sh
  4. 4 6
      kelp/setup.py
  5. 1 1
      mojolicious/install.sh
  6. 3 10
      mojolicious/setup.py
  7. 1 1
      plack/install.sh
  8. 6 8
      plack/setup.py
  9. 1 1
      web-simple/install.sh
  10. 4 6
      web-simple/setup.py

+ 1 - 1
dancer/install.sh

@@ -2,5 +2,5 @@
 
 fw_depends perl
 
-perl-5.18/bin/cpanm --notest --no-man-page Dancer Dancer::Plugin::Database DBI DBD::mysql JSON::XS Plack Starman
+cpanm --notest --no-man-page Dancer Dancer::Plugin::Database DBI DBD::mysql JSON::XS Plack Starman
 echo installed Dancer app dependencies

+ 4 - 6
dancer/setup.py

@@ -5,16 +5,14 @@ from os.path import expanduser
 import os
 import getpass
 
-home = expanduser("~")
-
 def start(args, logfile, errfile):
-  setup_util.replace_text("dancer/app.pl", "localhost", ""+ args.database_host +"")
+  setup_util.replace_text("dancer/app.pl", "localhost", args.database_host)
   setup_util.replace_text("dancer/nginx.conf", "USR", getpass.getuser())
-  setup_util.replace_text("dancer/nginx.conf", "server unix:.*\/FrameworkBenchmarks", "server unix:" + home + "/FrameworkBenchmarks")
+  setup_util.replace_text("dancer/nginx.conf", "server unix:.*\/FrameworkBenchmarks", "server unix:" + args.fwroot)
 
   try:
-    subprocess.Popen("plackup -E production -s Starman --workers=" + str(args.max_threads) + " -l " + home + "/FrameworkBenchmarks/dancer/frameworks-benchmark.sock -a ./app.pl", shell=True, cwd="dancer", stderr=errfile, stdout=logfile)
-    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/dancer/nginx.conf", shell=True, stderr=errfile, stdout=logfile)
+    subprocess.Popen("plackup -E production -s Starman --workers=" + str(args.max_threads) + " -l $TROOT/frameworks-benchmark.sock -a ./app.pl", shell=True, cwd="dancer", 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

+ 1 - 1
kelp/install.sh

@@ -2,5 +2,5 @@
 
 fw_depends perl
 
-perl-5.18/bin/cpanm --notest --no-man-page Kelp DBI DBD::mysql Kelp::Module::JSON::XS Plack Starman
+cpanm --notest --no-man-page Kelp DBI DBD::mysql Kelp::Module::JSON::XS Plack Starman
 echo installed Kelp app dependencies

+ 4 - 6
kelp/setup.py

@@ -5,16 +5,14 @@ from os.path import expanduser
 import os
 import getpass
 
-home = expanduser("~")
-
 def start(args, logfile, errfile):
-  setup_util.replace_text("kelp/app.pl", "localhost", ""+ args.database_host +"")
+  setup_util.replace_text("kelp/app.pl", "localhost", args.database_host)
   setup_util.replace_text("kelp/nginx.conf", "USR", getpass.getuser())
-  setup_util.replace_text("kelp/nginx.conf", "server unix:.*\/FrameworkBenchmarks", "server unix:" + home + "/FrameworkBenchmarks")
+  setup_util.replace_text("kelp/nginx.conf", "server unix:.*\/FrameworkBenchmarks", "server unix:" + args.fwroot)
 
   try:
-    subprocess.Popen("plackup -E production -s Starman --workers=" + str(args.max_threads) + " -l " + home + "/FrameworkBenchmarks/kelp/frameworks-benchmark.sock -a ./app.pl", shell=True, cwd="kelp", stderr=errfile, stdout=logfile)
-    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/kelp/nginx.conf", shell=True, stderr=errfile, stdout=logfile)
+    subprocess.Popen("plackup -E production -s Starman --workers=" + str(args.max_threads) + " -l $TROOT/frameworks-benchmark.sock -a $TROOT/app.pl", shell=True, cwd="kelp", 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

+ 1 - 1
mojolicious/install.sh

@@ -2,5 +2,5 @@
 
 fw_depends perl
 
-perl-5.18/bin/cpanm --notest --no-man-page --installdeps ../mojolicious
+cpanm --notest --no-man-page --installdeps $TROOT
 echo installed Mojolicious app dependencies

+ 3 - 10
mojolicious/setup.py

@@ -14,22 +14,15 @@ def start(args, logfile, errfile):
 
   try:
     # os.environ["MOJO_MODE"] = "production"
-    subprocess.Popen("hypnotoad ./app.pl", shell=True, cwd="mojolicious", stderr=errfile, stdout=logfile)
+    subprocess.Popen("hypnotoad $TROOT/app.pl", shell=True, cwd="mojolicious", stderr=errfile, stdout=logfile)
     return 0
   except subprocess.CalledProcessError:
     return 1
 
 def stop(logfile, errfile):
   try:
-    subprocess.call("hypnotoad -s ./app.pl", shell=True, cwd="mojolicious", stderr=errfile, stdout=logfile)
-    #p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-    #out, err = p.communicate()
-    #for line in out.splitlines():
-    #  if 'hypnotoad' in line:
-    #    pid = int(line.split(None, 2)[1])
-    #    os.kill(pid, 15)
+    subprocess.call("hypnotoad -s $TROOT/app.pl", shell=True, cwd="mojolicious", stderr=errfile, stdout=logfile)
     return 0
-  except subprocess.CalledProcessError as e:
-    print e
+  except subprocess.CalledProcessError:
     return 1
 

+ 1 - 1
plack/install.sh

@@ -2,5 +2,5 @@
 
 fw_depends perl
 
-perl-5.18/bin/cpanm --notest --no-man-page --installdeps ../plack
+cpanm --notest --no-man-page --installdeps $TROOT
 echo installed Plack app dependencies

+ 6 - 8
plack/setup.py

@@ -5,22 +5,20 @@ from os.path import expanduser
 import os
 import getpass
 
-home = expanduser("~")
-
 def start(args, logfile, errfile):
-  setup_util.replace_text("plack/app.psgi", "localhost", ""+ args.database_host +"")
+  setup_util.replace_text("plack/app.psgi", "localhost", args.database_host)
   setup_util.replace_text("plack/nginx.conf", "USR", getpass.getuser())
-  setup_util.replace_text("plack/nginx.conf", "server unix:.*\/FrameworkBenchmarks", "server unix:" + home + "/FrameworkBenchmarks")
+  setup_util.replace_text("plack/nginx.conf", "server unix:.*\/FrameworkBenchmarks", "server unix:" + arg.fwroot)
   try:
-    subprocess.Popen("start_server --backlog=16384 --pid-file="+home+"/FrameworkBenchmarks/plack/app.pid --path="+home+"/FrameworkBenchmarks/plack/app.sock -- plackup -E production -s Starlet --max-keepalive-reqs 1000 --max-reqs-per-child 50000 --min-reqs-per-child 40000 --max-workers=" + str(args.max_threads+4) + " -a "+home+"/FrameworkBenchmarks/plack/app.psgi", shell=True, cwd="plack", stderr=errfile, stdout=logfile)
-    subprocess.check_call("/usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/plack/nginx.conf", shell=True,stderr=errfile, stdout=logfile)
+    subprocess.Popen("start_server --backlog=16384 --pid-file=$TROOT/app.pid --path=$TROOT/app.sock -- plackup -E production -s Starlet --max-keepalive-reqs 1000 --max-reqs-per-child 50000 --min-reqs-per-child 40000 --max-workers=" + str(args.max_threads+4) + " -a $TROOT/app.psgi", shell=True, cwd="plack", stderr=errfile, stdout=logfile)
+    subprocess.check_call("/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('kill -TERM $(cat '+home+"/FrameworkBenchmarks/plack/app.pid)", shell=True, stderr=errfile, stdout=logfile)
-    subprocess.call("/usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/plack/nginx.conf -s stop", shell=True, stderr=errfile, stdout=logfile)
+    subprocess.call('kill -TERM $(cat $TROOT/app.pid)', shell=True, stderr=errfile, stdout=logfile)
+    subprocess.call("/usr/local/nginx/sbin/nginx -c $TROOT/nginx.conf -s stop", shell=True, stderr=errfile, stdout=logfile)
     return 0
   except subprocess.CalledProcessError:
     return 1

+ 1 - 1
web-simple/install.sh

@@ -2,5 +2,5 @@
 
 fw_depends perl
 
-perl-5.18/bin/cpanm --notest --no-man-page Web::Simple DBI DBD::mysql Plack Starman JSON::XS
+cpanm --notest --no-man-page Web::Simple DBI DBD::mysql Plack Starman JSON::XS
 echo installed Web::Simple app dependencies

+ 4 - 6
web-simple/setup.py

@@ -5,16 +5,14 @@ from os.path import expanduser
 import os
 import getpass
 
-home = expanduser("~")
-
 def start(args, logfile, errfile):
-  setup_util.replace_text("web-simple/app.pl", "localhost", ""+ args.database_host +"")
+  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", "server unix:" + home + "/FrameworkBenchmarks")
+  setup_util.replace_text("web-simple/nginx.conf", "server unix:.*\/FrameworkBenchmarks", "server unix:" + args.fwroot)
 
   try:
-    subprocess.Popen("plackup -E production -s Starman --workers=" + str(args.max_threads) + " -l " + home + "/FrameworkBenchmarks/web-simple/frameworks-benchmark.sock -a ./app.pl", shell=True, cwd="web-simple", stderr=errfile, stdout=logfile)
-    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/web-simple/nginx.conf", shell=True, stderr=errfile, stdout=logfile)
+    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