[DAEMONS][TwitterBridge] Set PUBLICDIR
This commit is contained in:
parent
3f56459734
commit
fe3e33e702
@ -1,24 +1,27 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 2009, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @copyright 2008, 2009 StatusNet, Inc
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
|
||||
define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
|
||||
|
||||
$shortoptions = 'di::';
|
||||
$longoptions = array('id::', 'debug');
|
||||
@ -56,9 +59,12 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
function __construct($id = null, $interval = 60,
|
||||
$max_children = 2, $debug = null)
|
||||
{
|
||||
public function __construct(
|
||||
$id = null,
|
||||
$interval = 60,
|
||||
$max_children = 2,
|
||||
$debug = null
|
||||
) {
|
||||
parent::__construct($id, $interval, $max_children, $debug);
|
||||
}
|
||||
|
||||
@ -67,7 +73,7 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
|
||||
*
|
||||
* @return string Name of the daemon.
|
||||
*/
|
||||
function name()
|
||||
public function name()
|
||||
{
|
||||
return ('synctwitterfriends.' . $this->_id);
|
||||
}
|
||||
@ -78,7 +84,7 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
|
||||
*
|
||||
* @return array flinks an array of Foreign_link objects
|
||||
*/
|
||||
function getObjects()
|
||||
public function getObjects()
|
||||
{
|
||||
$flinks = array();
|
||||
$flink = new Foreign_link();
|
||||
@ -105,7 +111,8 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
|
||||
}
|
||||
|
||||
// FIXME: make it so we can force a Foreign_link here without colliding with parent
|
||||
function childTask($flink) {
|
||||
public function childTask($flink)
|
||||
{
|
||||
// Each child ps needs its own DB connection
|
||||
|
||||
// Note: DataObject::getDatabaseConnection() creates
|
||||
@ -125,7 +132,7 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
|
||||
unset($_DB_DATAOBJECT['CONNECTIONS']);
|
||||
}
|
||||
|
||||
function fetchTwitterFriends(Foreign_link $flink)
|
||||
public function fetchTwitterFriends(Foreign_link $flink)
|
||||
{
|
||||
$friends = array();
|
||||
|
||||
@ -168,15 +175,17 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $pages; $i++) {
|
||||
|
||||
try {
|
||||
$more_friends = $client->statusesFriends(null, null, null, $i);
|
||||
} catch (Exception $e) {
|
||||
common_log(LOG_WARNING, $this->name() .
|
||||
' - cURL error getting Twitter statuses/friends ' .
|
||||
"page $i - " . $e->getCode() . ' - ' .
|
||||
$e->getMessage());
|
||||
}
|
||||
try {
|
||||
$more_friends = $client->statusesFriends(null, null, null, $i);
|
||||
} catch (Exception $e) {
|
||||
common_log(
|
||||
LOG_WARNING,
|
||||
$this->name() .
|
||||
' - cURL error getting Twitter statuses/friends ' .
|
||||
"page {$i} - " . $e->getCode() . ' - ' .
|
||||
$e->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($more_friends)) {
|
||||
common_log(LOG_WARNING, $this->name() .
|
||||
@ -193,7 +202,7 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
|
||||
return $friends;
|
||||
}
|
||||
|
||||
function subscribeTwitterFriends(Foreign_link $flink)
|
||||
public function subscribeTwitterFriends(Foreign_link $flink)
|
||||
{
|
||||
try {
|
||||
$profile = $flink->getProfile();
|
||||
@ -211,7 +220,6 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
|
||||
}
|
||||
|
||||
foreach ($friends as $friend) {
|
||||
|
||||
$friend_name = $friend->screen_name;
|
||||
$friend_id = (int) $friend->id;
|
||||
|
||||
@ -232,9 +240,11 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
|
||||
$friend_profile = $friend_flink->getProfile();
|
||||
|
||||
Subscription::start($profile, $friend_profile);
|
||||
common_log(LOG_INFO,
|
||||
$this->name() . ' - Subscribed ' .
|
||||
"{$friend_profile->nickname} to {$profile->nickname}.");
|
||||
common_log(
|
||||
LOG_INFO,
|
||||
$this->name() . ' - Subscribed ' .
|
||||
"{$friend_profile->nickname} to {$profile->nickname}."
|
||||
);
|
||||
} catch (NoResultException $e) {
|
||||
// either no foreign link for this friend's foreign ID or no profile found on local ID.
|
||||
} catch (Exception $e) {
|
||||
@ -247,7 +257,6 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$id = null;
|
||||
@ -255,9 +264,9 @@ $debug = null;
|
||||
|
||||
if (have_option('i')) {
|
||||
$id = get_option_value('i');
|
||||
} else if (have_option('--id')) {
|
||||
} elseif (have_option('--id')) {
|
||||
$id = get_option_value('--id');
|
||||
} else if (count($args) > 0) {
|
||||
} elseif (count($args) > 0) {
|
||||
$id = $args[0];
|
||||
} else {
|
||||
$id = null;
|
||||
|
@ -1,24 +1,27 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/*
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008-2010, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @copyright 2008-2010 StatusNet, Inc
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
|
||||
define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
|
||||
|
||||
$shortoptions = 'fi::a';
|
||||
$longoptions = array('id::', 'foreground', 'all');
|
||||
@ -39,7 +42,7 @@ class TwitterDaemon extends SpawningDaemon
|
||||
{
|
||||
protected $allsites = false;
|
||||
|
||||
function __construct($id=null, $daemonize=true, $threads=1, $allsites=false)
|
||||
public function __construct($id = null, $daemonize = true, $threads = 1, $allsites = false)
|
||||
{
|
||||
if ($threads != 1) {
|
||||
// This should never happen. :)
|
||||
@ -49,7 +52,7 @@ class TwitterDaemon extends SpawningDaemon
|
||||
$this->allsites = $allsites;
|
||||
}
|
||||
|
||||
function runThread()
|
||||
public function runThread()
|
||||
{
|
||||
common_log(LOG_INFO, 'Waiting to listen to Twitter and queues');
|
||||
|
||||
@ -61,14 +64,13 @@ class TwitterDaemon extends SpawningDaemon
|
||||
|
||||
return $master->respawn ? self::EXIT_RESTART : self::EXIT_SHUTDOWN;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TwitterMaster extends IoMaster
|
||||
{
|
||||
protected $processManager;
|
||||
|
||||
function __construct($id, $processManager)
|
||||
public function __construct($id, $processManager)
|
||||
{
|
||||
parent::__construct($id);
|
||||
$this->processManager = $processManager;
|
||||
@ -78,7 +80,7 @@ class TwitterMaster extends IoMaster
|
||||
* Initialize IoManagers for the currently configured site
|
||||
* which are appropriate to this instance.
|
||||
*/
|
||||
function initManagers()
|
||||
public function initManagers()
|
||||
{
|
||||
$qm = QueueManager::get();
|
||||
$qm->setActiveGroup('twitter');
|
||||
@ -298,7 +300,7 @@ class TwitterManager extends IoManager
|
||||
|
||||
if (have_option('i', 'id')) {
|
||||
$id = get_option_value('i', 'id');
|
||||
} else if (count($args) > 0) {
|
||||
} elseif (count($args) > 0) {
|
||||
$id = $args[0];
|
||||
} else {
|
||||
$id = null;
|
||||
|
@ -1,24 +1,27 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||
//
|
||||
// GNU social is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// GNU social 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008-2010, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @copyright 2008-2010 StatusNet, Inc
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
|
||||
define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
|
||||
|
||||
// Tune number of processes and how often to poll Twitter
|
||||
// XXX: Should these things be in config.php?
|
||||
@ -74,9 +77,12 @@ class TwitterStatusFetcher extends ParallelizingDaemon
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
function __construct($id = null, $interval = 60,
|
||||
$max_children = 2, $debug = null)
|
||||
{
|
||||
public function __construct(
|
||||
$id = null,
|
||||
$interval = 60,
|
||||
$max_children = 2,
|
||||
$debug = null
|
||||
) {
|
||||
parent::__construct($id, $interval, $max_children, $debug);
|
||||
}
|
||||
|
||||
@ -85,7 +91,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon
|
||||
*
|
||||
* @return string Name of the daemon.
|
||||
*/
|
||||
function name()
|
||||
public function name()
|
||||
{
|
||||
return ('twitterstatusfetcher.'.$this->_id);
|
||||
}
|
||||
@ -96,7 +102,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon
|
||||
*
|
||||
* @return array flinks an array of Foreign_link objects
|
||||
*/
|
||||
function getObjects()
|
||||
public function getObjects()
|
||||
{
|
||||
global $_DB_DATAOBJECT;
|
||||
$flink = new Foreign_link();
|
||||
@ -109,7 +115,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon
|
||||
$flinks = array();
|
||||
|
||||
while ($flink->fetch()) {
|
||||
|
||||
if (($flink->noticesync & FOREIGN_NOTICE_RECV) ==
|
||||
FOREIGN_NOTICE_RECV) {
|
||||
$flinks[] = clone($flink);
|
||||
@ -129,7 +134,8 @@ class TwitterStatusFetcher extends ParallelizingDaemon
|
||||
}
|
||||
|
||||
// FIXME: make it so we can force a Foreign_link here without colliding with parent
|
||||
function childTask($flink) {
|
||||
public function childTask($flink)
|
||||
{
|
||||
// Each child ps needs its own DB connection
|
||||
|
||||
// Note: DataObject::getDatabaseConnection() creates
|
||||
@ -150,7 +156,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon
|
||||
unset($_DB_DATAOBJECT['CONNECTIONS']);
|
||||
}
|
||||
|
||||
function getTimeline(Foreign_link $flink, $timelineUri = 'home_timeline')
|
||||
public function getTimeline(Foreign_link $flink, $timelineUri = 'home_timeline')
|
||||
{
|
||||
common_log(LOG_DEBUG, $this->name() . ' - Trying to get ' . $timelineUri .
|
||||
' timeline for Twitter user ' . $flink->foreign_id);
|
||||
@ -219,9 +225,9 @@ $debug = null;
|
||||
|
||||
if (have_option('i')) {
|
||||
$id = get_option_value('i');
|
||||
} else if (have_option('--id')) {
|
||||
} elseif (have_option('--id')) {
|
||||
$id = get_option_value('--id');
|
||||
} else if (count($args) > 0) {
|
||||
} elseif (count($args) > 0) {
|
||||
$id = $args[0];
|
||||
} else {
|
||||
$id = null;
|
||||
|
Loading…
Reference in New Issue
Block a user