change scripts to take server and path from commandline

This commit is contained in:
Evan Prodromou 2009-06-20 14:58:47 -07:00
parent 45430d2b3b
commit 198afa0a1d
15 changed files with 109 additions and 33 deletions

View File

@ -67,14 +67,25 @@ function _sn_to_path($sn)
return $p; return $p;
} }
// try to figure out where we are // try to figure out where we are. $server and $path
// can be set by including module, else we guess based
// on HTTP info.
$_server = array_key_exists('SERVER_NAME', $_SERVER) ? if (isset($server)) {
strtolower($_SERVER['SERVER_NAME']) : $_server = $server;
null; } else {
$_path = array_key_exists('SCRIPT_NAME', $_SERVER) ? $_server = array_key_exists('SERVER_NAME', $_SERVER) ?
_sn_to_path($_SERVER['SCRIPT_NAME']) : strtolower($_SERVER['SERVER_NAME']) :
null; null;
}
if (isset($path)) {
$_path = $path;
} else {
$_path = array_key_exists('SCRIPT_NAME', $_SERVER) ?
_sn_to_path($_SERVER['SCRIPT_NAME']) :
null;
}
// default configuration, overwritten in config.php // default configuration, overwritten in config.php

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/mail.php'); require_once(INSTALLDIR . '/lib/mail.php');
require_once(INSTALLDIR . '/lib/queuehandler.php'); require_once(INSTALLDIR . '/lib/queuehandler.php');
@ -35,7 +40,6 @@ set_error_handler('common_error_handler');
class EnjitQueueHandler extends QueueHandler class EnjitQueueHandler extends QueueHandler
{ {
function transport() function transport()
{ {
return 'enjit'; return 'enjit';
@ -60,7 +64,6 @@ class EnjitQueueHandler extends QueueHandler
return "skipped"; return "skipped";
} }
# #
# Build an Atom message from the notice # Build an Atom message from the notice
# #
@ -93,8 +96,8 @@ class EnjitQueueHandler extends QueueHandler
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1) ; curl_setopt($ch, CURLOPT_POST, 1) ;
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
@ -103,7 +106,7 @@ class EnjitQueueHandler extends QueueHandler
# #
# curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); # curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
# curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); # curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
# curl_setopt($ch, CURLOPT_VERBOSE, 1); # curl_setopt($ch, CURLOPT_VERBOSE, 1);
$result = curl_exec($ch); $result = curl_exec($ch);
@ -115,7 +118,6 @@ class EnjitQueueHandler extends QueueHandler
return $code; return $code;
} }
} }

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/facebookutil.php'); require_once(INSTALLDIR . '/lib/facebookutil.php');
require_once(INSTALLDIR . '/lib/queuehandler.php'); require_once(INSTALLDIR . '/lib/queuehandler.php');
@ -35,12 +40,12 @@ set_error_handler('common_error_handler');
class FacebookQueueHandler extends QueueHandler class FacebookQueueHandler extends QueueHandler
{ {
function transport() function transport()
{ {
return 'facebook'; return 'facebook';
} }
function start() function start()
{ {
$this->log(LOG_INFO, "INITIALIZE"); $this->log(LOG_INFO, "INITIALIZE");
@ -51,7 +56,7 @@ class FacebookQueueHandler extends QueueHandler
{ {
return facebookBroadcastNotice($notice); return facebookBroadcastNotice($notice);
} }
function finish() function finish()
{ {
} }

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/jabber.php'); require_once(INSTALLDIR . '/lib/jabber.php');
require_once(INSTALLDIR . '/lib/xmppqueuehandler.php'); require_once(INSTALLDIR . '/lib/xmppqueuehandler.php');

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 1) ? $argv[1] : null;
$path = ($argc > 2) ? $argv[2] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/mail.php'); require_once(INSTALLDIR . '/lib/mail.php');
require_once('Mail/mimeDecode.php'); require_once('Mail/mimeDecode.php');
@ -36,7 +41,6 @@ require_once('Mail/mimeDecode.php');
class MailerDaemon class MailerDaemon
{ {
function __construct() function __construct()
{ {
} }

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/omb.php'); require_once(INSTALLDIR . '/lib/omb.php');
require_once(INSTALLDIR . '/lib/queuehandler.php'); require_once(INSTALLDIR . '/lib/queuehandler.php');
@ -35,12 +40,12 @@ set_error_handler('common_error_handler');
class OmbQueueHandler extends QueueHandler class OmbQueueHandler extends QueueHandler
{ {
function transport() function transport()
{ {
return 'omb'; return 'omb';
} }
function start() function start()
{ {
$this->log(LOG_INFO, "INITIALIZE"); $this->log(LOG_INFO, "INITIALIZE");
@ -56,7 +61,7 @@ class OmbQueueHandler extends QueueHandler
return omb_broadcast_remote_subscribers($notice); return omb_broadcast_remote_subscribers($notice);
} }
} }
function finish() function finish()
{ {
} }

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/ping.php'); require_once(INSTALLDIR . '/lib/ping.php');
require_once(INSTALLDIR . '/lib/queuehandler.php'); require_once(INSTALLDIR . '/lib/queuehandler.php');

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/jabber.php'); require_once(INSTALLDIR . '/lib/jabber.php');
require_once(INSTALLDIR . '/lib/xmppqueuehandler.php'); require_once(INSTALLDIR . '/lib/xmppqueuehandler.php');
@ -35,12 +40,12 @@ set_error_handler('common_error_handler');
class PublicQueueHandler extends XmppQueueHandler class PublicQueueHandler extends XmppQueueHandler
{ {
function transport() function transport()
{ {
return 'public'; return 'public';
} }
function handle_notice($notice) function handle_notice($notice)
{ {
try { try {

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/mail.php'); require_once(INSTALLDIR . '/lib/mail.php');
require_once(INSTALLDIR . '/lib/queuehandler.php'); require_once(INSTALLDIR . '/lib/queuehandler.php');
@ -35,7 +40,7 @@ set_error_handler('common_error_handler');
class SmsQueueHandler extends QueueHandler class SmsQueueHandler extends QueueHandler
{ {
function transport() function transport()
{ {
return 'sms'; return 'sms';
@ -51,7 +56,7 @@ class SmsQueueHandler extends QueueHandler
{ {
return mail_broadcast_notice_sms($notice); return mail_broadcast_notice_sms($notice);
} }
function finish() function finish()
{ {
} }

View File

@ -30,6 +30,11 @@ define('LACONICA', true);
// Uncomment this to get useful console output // Uncomment this to get useful console output
//define('SCRIPT_DEBUG', true); //define('SCRIPT_DEBUG', true);
// Preset the server at the command line
$server = ($argc > 1) ? $argv[1] : null;
$path = ($argc > 2) ? $argv[2] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
// Make a lockfile // Make a lockfile

View File

@ -32,6 +32,11 @@ mb_internal_encoding('UTF-8');
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
$user = new User(); $user = new User();
@ -74,10 +79,10 @@ while ($user->fetch()) {
$delay = 3.0 * ($finish - $start); $delay = 3.0 * ($finish - $start);
print "Delaying $delay seconds..."; print "Delaying $delay seconds...";
// Wait to let slaves catch up // Wait to let slaves catch up
usleep($delay * 1000000); usleep($delay * 1000000);
print "DONE.\n"; print "DONE.\n";
} }

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/twitter.php'); require_once(INSTALLDIR . '/lib/twitter.php');
require_once(INSTALLDIR . '/lib/queuehandler.php'); require_once(INSTALLDIR . '/lib/queuehandler.php');
@ -35,12 +40,12 @@ set_error_handler('common_error_handler');
class TwitterQueueHandler extends QueueHandler class TwitterQueueHandler extends QueueHandler
{ {
function transport() function transport()
{ {
return 'twitter'; return 'twitter';
} }
function start() function start()
{ {
$this->log(LOG_INFO, "INITIALIZE"); $this->log(LOG_INFO, "INITIALIZE");
@ -51,7 +56,7 @@ class TwitterQueueHandler extends QueueHandler
{ {
return broadcast_twitter($notice); return broadcast_twitter($notice);
} }
function finish() function finish()
{ {
} }

View File

@ -33,7 +33,12 @@ define('MAXCHILDREN', 2);
define('POLL_INTERVAL', 60); // in seconds define('POLL_INTERVAL', 60); // in seconds
// Uncomment this to get useful logging // Uncomment this to get useful logging
define('SCRIPT_DEBUG', true); // define('SCRIPT_DEBUG', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once INSTALLDIR . '/lib/common.php'; require_once INSTALLDIR . '/lib/common.php';
require_once INSTALLDIR . '/lib/daemon.php'; require_once INSTALLDIR . '/lib/daemon.php';

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/jabber.php'); require_once(INSTALLDIR . '/lib/jabber.php');
require_once(INSTALLDIR . '/lib/xmppqueuehandler.php'); require_once(INSTALLDIR . '/lib/xmppqueuehandler.php');
@ -39,12 +44,12 @@ class XmppConfirmHandler extends XmppQueueHandler
{ {
var $_id = 'confirm'; var $_id = 'confirm';
function class_name() function class_name()
{ {
return 'XmppConfirmHandler'; return 'XmppConfirmHandler';
} }
function run() function run()
{ {
if (!$this->start()) { if (!$this->start()) {

View File

@ -27,6 +27,11 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
// Preset the server at the command line
$server = ($argc > 2) ? $argv[2] : null;
$path = ($argc > 3) ? $argv[3] : null;
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/jabber.php'); require_once(INSTALLDIR . '/lib/jabber.php');
require_once(INSTALLDIR . '/lib/daemon.php'); require_once(INSTALLDIR . '/lib/daemon.php');
@ -39,7 +44,6 @@ set_error_handler('common_error_handler');
class XMPPDaemon extends Daemon class XMPPDaemon extends Daemon
{ {
function XMPPDaemon($resource=null) function XMPPDaemon($resource=null)
{ {
static $attrs = array('server', 'port', 'user', 'password', 'host'); static $attrs = array('server', 'port', 'user', 'password', 'host');