Browse Source

master Servicestack was not killing nginx

This caused every test to run after servicestack which tried to bind
to port 8080, to fail. I added a clean kill command for the master
nginx process.

Servicestack-nginx-default still fails to run properly for other
reasons, but at least it will no longer be zombie-bound to port 8080.
Mike Smith 11 years ago
parent
commit
2cedab4a18
1 changed files with 13 additions and 2 deletions
  1. 13 2
      servicestack/setup_nginx.py

+ 13 - 2
servicestack/setup_nginx.py

@@ -20,8 +20,8 @@ def start(args, logfile, errfile):
     
     # nginx
     workers = 'worker_processes ' + str(args.max_threads) + ';'
-    subprocess.check_call('echo "upstream mono {\n' + ';\n'.join('\tserver 127.0.0.1:' + str(port) for port in range(9001, 9001 + args.max_threads)) + ';\n}" > ' + root + '/nginx.upstream.conf', shell=True, stderr=errfile, stdout=logfile);
-    subprocess.check_call('sudo /usr/local/nginx/sbin/nginx -c ' + root + '/nginx.conf -g "' + workers + '"', shell=True, stderr=errfile, stdout=logfile)
+    #subprocess.check_call('echo "upstream mono {\n' + ';\n'.join('\tserver 127.0.0.1:' + str(port) for port in range(9001, 9001 + args.max_threads)) + ';\n}" > ' + root + '/nginx.upstream.conf', shell=True, stderr=errfile, stdout=logfile);
+    subprocess.check_call('/usr/local/nginx/sbin/nginx -c ' + root + '/nginx.conf -g "' + workers + '"', shell=True, stderr=errfile, stdout=logfile)
     
     # fastcgi
     for port in range(9001, 9001 + args.max_threads):
@@ -43,5 +43,16 @@ def stop(logfile, errfile):
     if 'mono-server' in line:
       pid = int(line.split(None, 2)[1])
       os.kill(pid, 9)
+
+  #
+  # stop nginx
+  #
+  p2 = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p2.communicate()
+  for line in out.splitlines():
+    if 'sbin/nginx' in line:
+      pid = int(line.split(None, 2)[1])
+      os.kill(pid, 15)
+
   return 0