jwarnier
2010-08-17 9b82d2915ca6b4b3f1112b5b3167eed1a888c56a
Slightly improve process matching with a well-known UNIX shell trick.


1 files modified
6 ■■■■ changed files
server/server.php 6 ●●●● patch | view | raw | blame | history
server/server.php
@@ -67,12 +67,12 @@
}
// Check if another process is running
// Check whether another instance of this script is already running
if(is_file($conf["temppath"].$conf["fs_div"].".ispconfig_lock")){
  clearstatcache();
  for($i=0;$i<120;$i++){ // Wait max. 1200 sec, then proceed
  for($i=0;$i<120;$i++){ // Wait max. 1200 sec, then retry
    if(is_file($conf["temppath"].$conf["fs_div"].".ispconfig_lock")){
      exec("ps aux | grep '/usr/local/ispconfig/server/server.php' | grep -v 'grep' | wc -l", $check);
      exec("ps aux | grep '/usr/local/ispconfig/server/[s]erver.php' | wc -l", $check);
      if(intval($check[0]) > 1) { // 1 because this is 2nd instance!
          $app->log("There is already an instance of server.php running. Exiting.", LOGLEVEL_DEBUG);
          exit;