File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed
Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change 128128// Check whether another instance of this script is already running
129129if (is_file ($ conf ['temppath ' ] . $ conf ['fs_div ' ] . '.ispconfig_lock ' )) {
130130 clearstatcache ();
131- for ($ i = 0 ; $ i < 120 ; $ i ++) { // Wait max. 1200 sec, then retry
132- if (is_file ($ conf ['temppath ' ] . $ conf ['fs_div ' ] . '.ispconfig_lock ' )) {
133- exec ("ps aux | grep '/usr/local/ispconfig/server/[s]erver.php' | wc -l " , $ check );
134- if (intval ($ check [0 ]) > 1 ) { // 1 because this is 2nd instance!
135- $ app ->log ('There is already an instance of server.php running. Exiting. ' , LOGLEVEL_DEBUG );
136- exit ;
137- }
138- $ app ->log ('There is already a lockfile set. Waiting another 10 seconds... ' , LOGLEVEL_DEBUG );
139- sleep (10 );
140- clearstatcache ();
131+ $ pid = trim (file_get_contents ($ conf ['temppath ' ] . $ conf ['fs_div ' ] . '.ispconfig_lock ' ));
132+ if (preg_match ('/^[0-9]+$/ ' , $ pid )) {
133+ if (file_exists ('/proc/ ' . $ pid )) {
134+ $ app ->log ('There is already an instance of server.php running with pid ' . $ pid . '. ' , LOGLEVEL_DEBUG );
135+ exit ;
141136 }
142137 }
138+ $ app ->log ('There is already a lockfile set, but no process running with this pid ( ' . $ pid . '). Continuing. ' , LOGLEVEL_WARN );
143139}
144140
145141// Set Lockfile
146- @touch ($ conf ['temppath ' ] . $ conf ['fs_div ' ] . '.ispconfig_lock ' );
142+ @file_put_contents ($ conf ['temppath ' ] . $ conf ['fs_div ' ] . '.ispconfig_lock ' , getmypid () );
147143$ app ->log ('Set Lock: ' . $ conf ['temppath ' ] . $ conf ['fs_div ' ] . '.ispconfig_lock ' , LOGLEVEL_DEBUG );
148144
149145/** Do we need to start the core-modules */
You can’t perform that action at this time.
0 commit comments