Browse Source

do not use sudo. tune number of process

Masahiro Nagano 11 years ago
parent
commit
f0988b5c61
2 changed files with 6 additions and 7 deletions
  1. 2 3
      plack/nginx.conf
  2. 4 4
      plack/setup.py

+ 2 - 3
plack/nginx.conf

@@ -1,6 +1,5 @@
-user tfb;
 error_log stderr error;
-
+pid        /tmp/nginx.pid;
 worker_processes 4;
 
 events {
@@ -16,7 +15,7 @@ http {
 
   upstream backendurl {
     server unix:/home/tfb/FrameworkBenchmarks/plack/app.sock;
-    keepalive 20;
+    keepalive 8;
   }
 
   server {

+ 4 - 4
plack/setup.py

@@ -14,15 +14,15 @@ def start(args, logfile, errfile):
   try:
     subprocess.check_call("curl -L http://cpanmin.us | perl - App::cpanminus", shell=True, cwd="plack", stderr=errfile, stdout=logfile)
     subprocess.check_call("cpanm --notest --no-man-pages --installdeps "+home+"/FrameworkBenchmarks/plack", shell=True, cwd="plack", stderr=errfile, stdout=logfile)
-    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+128) + " -a "+home+"/FrameworkBenchmarks/plack/app.psgi", shell=True, cwd="plack", stderr=errfile, stdout=logfile)
-    subprocess.check_call("sudo /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="+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)
     return 0
   except subprocess.CalledProcessError:
     return 1
 def stop(logfile, errfile):
   try:
-    subprocess.call('kill -TERM $(cat '+home+"/FrameworkBenchmarks/plack/app.pid)", shell=True, cwd="plack", stderr=errfile, stdout=logfile)
-    subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
+    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)
     return 0
   except subprocess.CalledProcessError:
     return 1