当前位置: 首页>>代码示例>>PHP>>正文


PHP Lock::lock方法代码示例

本文整理汇总了PHP中Lock::lock方法的典型用法代码示例。如果您正苦于以下问题:PHP Lock::lock方法的具体用法?PHP Lock::lock怎么用?PHP Lock::lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lock的用法示例。


在下文中一共展示了Lock::lock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLockOtherProcess

 /**
  * Trying to lock when previous launch of our app crashed
  * and left a lock file intact
  *
  * @covers Yeriomin\ConsoleApp\Lock::lock
  */
 public function testLockOtherProcess()
 {
     file_put_contents($this->testFileName, '99999999');
     $this->object->lock($this->testFileName);
     $this->assertFileExists($this->testFileName);
     $this->assertEquals(getmypid(), file_get_contents($this->testFileName));
 }
开发者ID:yeriomin,项目名称:console-app,代码行数:13,代码来源:LockTest.php

示例2: loadVars

 private function loadVars()
 {
     if (!$this->lock->lock()) {
         return;
     }
     if (!shm_has_var($this->memory, self::SID_VARS)) {
         $this->varNames = [];
         shm_put_var($this->memory, self::SID_VARS, $this->varNames);
     } else {
         $this->varNames = shm_get_var($this->memory, self::SID_VARS);
     }
     $this->lock->unlock();
 }
开发者ID:CrakLabs,项目名称:ipc-component,代码行数:13,代码来源:ShmMemory.php

示例3: define

// composer autoload
require_once __DIR__ . '/vendor/autoload.php';
// define the parent folder of this file as base path
define("BASE_PATH", dirname(__FILE__));
// check for a config file
if (file_exists(BASE_PATH . '/config.php')) {
    require_once BASE_PATH . '/config.php';
} else {
    trigger_error("AIESEC-Customer.io-Connector is missing a config file", E_USER_ERROR);
    die;
}
// instantiate KLogger (we don't catch anything here, because we can not do anything about it)
$log = new \Katzgrau\KLogger\Logger(LOG, LOGLEVEL);
$log->log(\Psr\Log\LogLevel::INFO, "AIESEC-Customer.io-Connector is starting.");
// try to get lock
$pid = Lock::lock($log);
// check if we got the lock
if ($pid < 1) {
    // there is a problem or another process running. Shutdown...
    $log->log(\Psr\Log\LogLevel::INFO, "AIESEC-Customer.io-Connector didn't got the lock. This instance is shutting down...");
} else {
    // we got the lock, so check that data directory is writeable
    if (!file_exists('./data') || !is_writeable('./data')) {
        die("data directory must be writeable");
    }
    //try to run the core and sync once
    try {
        $core = new Core($log);
        if ($core) {
            $core->run();
        }
开发者ID:kjschubert,项目名称:aiesec-customer.io-connector,代码行数:31,代码来源:run.php

示例4: testUnlock

 /**
  * Tests unlock().
  * 
  * @see Lock::unlock()
  */
 public function testUnlock()
 {
     $name = __FUNCTION__;
     $checkLock = new Lock($name);
     $lock = new Lock($name);
     $lock->lock();
     $lock->unlock();
     $this->assertTrue($checkLock->nonblockingLock());
     $checkLock->unlock();
 }
开发者ID:bmdevel,项目名称:bav,代码行数:15,代码来源:LockTest.php

示例5: Lock

<?php

require_once '../shell.php';
if (isset($_POST['ID'])) {
    $id = $_POST['ID'];
    $lock = new Lock($id);
    if ($lock->isLocked()) {
        $lock->unlock();
        $command = escapeshellcmd("python /var/www/python/clear.py");
        echo $command;
        $output = shell_exec($command);
        echo "Output: {$output} <br>";
    } else {
        $lock->lock();
        $command = escapeshellcmd("python /var/www/python/LightsHandler.py allamb on");
        echo $command;
        $output = shell_exec($command);
        echo "Output: {$output} <br>";
    }
}
开发者ID:brd69125,项目名称:Smart_Home,代码行数:20,代码来源:nightMode.ajax.php

示例6: set_time_limit

<?php

set_time_limit(0);
$start_time = time("now");
require_once 'lib/config.php';
require_once 'lib/ebay/selling.php';
require_once 'lib/item.php';
if (isset($_GET['user_id'])) {
    $users = array(DB::query_row("SELECT * from ebay_users where `user_id`='{$_GET['user_id']}'"));
    $lock_file = LOCK_FILE . '_' . $_GET['user_id'];
} else {
    $users = DB::query_rows("SELECT * from ebay_users");
    $lock_file = LOCK_FILE . '';
}
if (!Lock::lock($lock_file, "LOCK", 0 * 3600)) {
    die('Another instance is already running: ' . Lock::get_msg($lock_file));
}
Log::push('----- Cron job started -----');
foreach ($users as $user) {
    $user_id = $user['user_id'];
    $DEVNAME = trim($user['dev_name']);
    $APPNAME = trim($user['app_name']);
    $CERTNAME = trim($user['cert_name']);
    $paypal_email = trim($user['paypal_address']);
    $token = decrypt($user['token']);
    /* Relisting inactive items */
    $items = EbaySelling::get_items('UnsoldList');
    foreach ($items as $num => $ebay_item) {
        if (!empty($_GET['num']) && $_GET['num'] != $num) {
            continue;
        }
开发者ID:eparst,项目名称:ebay-amazon-sync-tool,代码行数:31,代码来源:cron_job.php


注:本文中的Lock::lock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。