本文整理汇总了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;
}
}
示例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');
示例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');
示例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.
示例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;
}