Exemplo n.º 1
0
 /**
  * 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;
     }
 }
Exemplo n.º 2
0
        }
    } 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');
Exemplo n.º 3
0
// | 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 <*****@*****.**>                          |
// +----------------------------------------------------------------------+
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');
Exemplo n.º 4
0
<?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.
Exemplo n.º 5
0
 /**
  * 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;
 }