Browse Source

better start/stop script for php-fpm

Patrick Falls 12 years ago
parent
commit
f1182778c1
1 changed files with 4 additions and 12 deletions
  1. 4 12
      php/setup.py

+ 4 - 12
php/setup.py

@@ -18,24 +18,16 @@ def start(args):
     #subprocess.check_call("sudo a2ensite php", shell=True)
     #subprocess.check_call("sudo chown -R www-data:www-data php", shell=True)
     #subprocess.check_call("sudo /etc/init.d/apache2 start", shell=True)
-    subprocess.check_call("sudo php-fpm --fpm-config config/php-fpm.conf", shell=True)
-    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "FrameworkBenchmarks/php/deploy/nginx.conf", shell=True)
+    subprocess.check_call("sudo php-fpm --fpm-config config/php-fpm.conf -g " + home + "/FrameworkBenchmarks/php/deploy/php-fpm.pid", shell=True)
+    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + home + "/FrameworkBenchmarks/php/deploy/nginx.conf", shell=True)
     
     return 0
   except subprocess.CalledProcessError:
     return 1
 def stop():
   try:
-    subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
-    p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-    out, err = p.communicate()
-    for line in out.splitlines():
-      if 'php-fpm' in line:
-        try:
-          pid = int(line.split(None, 2)[1])
-          os.kill(pid, 9)
-        except OSError:
-          pass
+    subprocess.call("sudo /usr/local/nginx/sbin/nginx -s stop", shell=True)
+    subprocess.call("sudo kill -QUIT $( cat php/deploy/php-fpm.pid )", shell=True)
     
     return 0
   except subprocess.CalledProcessError: