當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Lock::getProcessID方法代碼示例

本文整理匯總了PHP中Lock::getProcessID方法的典型用法代碼示例。如果您正苦於以下問題:PHP Lock::getProcessID方法的具體用法?PHP Lock::getProcessID怎麽用?PHP Lock::getProcessID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Lock的用法示例。


在下文中一共展示了Lock::getProcessID方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: acquire

 /**
  * Creates a lock file for the given name.
  *
  * @access  public
  * @param   string $name The name of this lock file
  * @return  boolean
  */
 function acquire($name)
 {
     $pid = Lock::getProcessID($name);
     if (!empty($pid)) {
         return false;
     } else {
         // create the pid file
         $fp = @fopen(Lock::_getProcessFilename($name), 'w');
         @flock($fp, LOCK_EX);
         @fwrite($fp, getmypid());
         @flock($fp, LOCK_UN);
         @fclose($fp);
         return true;
     }
 }
開發者ID:juliogallardo1326,項目名稱:proc,代碼行數:22,代碼來源:class.lock.php

示例2: foreach

        }
    } else {
        foreach (array_keys($config) as $key) {
            if (isset($_GET[$key])) {
                $config[$key] = $_GET[$key];
            }
        }
    }
    return $config;
}
$config = getParams();
// if requested, clear the lock
if ($config['fix-lock']) {
    if (Lock::release('process_mail_queue')) {
        echo "The lock file was removed successfully.\n";
    }
    exit(0);
}
if (!Lock::acquire('process_mail_queue')) {
    $pid = Lock::getProcessID('process_mail_queue');
    fwrite(STDERR, "ERROR: There is already a process (pid={$pid}) of this script running.");
    fwrite(STDERR, "If this is not accurate, you may fix it by running this script with '--fix-lock' as the only parameter.\n");
    exit(1);
}
// handle only pending emails
$limit = 50;
Mail_Queue::send('pending', $limit);
// handle emails that we tried to send before, but an error happened...
$limit = 50;
Mail_Queue::send('error', $limit);
Lock::release('process_mail_queue');
開發者ID:dabielkabuto,項目名稱:eventum,代碼行數:31,代碼來源:process_mail_queue.php

示例3: ini_set

// | This program is distributed in the hope that it will be useful,      |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
// | GNU General Public License for more details.                         |
// |                                                                      |
// | You should have received a copy of the GNU General Public License    |
// | along with this program; if not, write to:                           |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 51 Franklin Street, Suite 330                                        |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: Bryan Alsdorf <balsdorf@gmail.com>                          |
// +----------------------------------------------------------------------+
ini_set('memory_limit', '1024M');
require_once dirname(__FILE__) . '/../init.php';
// if requested, clear the lock
if (in_array('--fix-lock', $argv)) {
    if (Lock::release('truncate_mail_queue')) {
        echo "The lock file was removed successfully.\n";
    }
    exit(0);
}
if (!Lock::acquire('truncate_mail_queue')) {
    $pid = Lock::getProcessID('truncate_mail_queue');
    fwrite(STDERR, "ERROR: There is already a process (pid={$pid}) of this script running.");
    fwrite(STDERR, "If this is not accurate, you may fix it by running this script with '--fix-lock' as the only parameter.\n");
    exit(1);
}
Mail_Queue::truncate();
Lock::release('truncate_mail_queue');
開發者ID:korusdipl,項目名稱:eventum,代碼行數:31,代碼來源:truncate_mail_queue.php

示例4:

<?php

include_once "../../config.inc.php";
include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.lock.php";
include_once APP_INC_PATH . "db_access.php";
Auth::checkAuthentication(APP_COOKIE);
if (Auth::getCurrentRole() < User::getRoleID("Developer")) {
    echo "Invalid role";
    exit;
}
$process_id = Lock::getProcessID('irc_bot');
echo "Existing process ID: {$process_id}<br />\n";
if (!empty($process_id)) {
    // kill current process
    $kill = `kill {$process_id}`;
    if (!empty($kill)) {
        echo "Killed: {$kill}<br />\n";
    }
}
Lock::release('irc_bot');
$start = `cd /var/www/html/eventum/misc/irc/;php -q bot.php > /dev/null &`;
if (!empty($start)) {
    echo "Error: {$start}<br />\n";
}
?>
<hr>
If there are no error messages above, the bot should have been successfully restarted.
開發者ID:juliogallardo1326,項目名稱:proc,代碼行數:28,代碼來源:restart.php

示例5: checkIRCBot

 /**
  * Checks on the status of the IRC bot.
  *
  * @return  integer Number of errors encountered.
  */
 public static function checkIRCBot()
 {
     $pid = Lock::getProcessID('irc_bot', true);
     if (!$pid) {
         echo ev_gettext('ERROR: Could not find IRC bot pid from process list.'), "\n";
         return 1;
     }
     return 0;
 }
開發者ID:dabielkabuto,項目名稱:eventum,代碼行數:14,代碼來源:class.monitor.php


注:本文中的Lock::getProcessID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。