当前位置: 首页>>代码示例>>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;未经允许,请勿转载。