From d283aa006ed42bfeb45b7a4dbff06ac94e52391d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 13 Jul 2011 13:23:09 -0400 Subject: [PATCH] script to garbage-collect old realtime channels --- plugins/Realtime/cleanupchannels.php | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 plugins/Realtime/cleanupchannels.php diff --git a/plugins/Realtime/cleanupchannels.php b/plugins/Realtime/cleanupchannels.php new file mode 100644 index 0000000000..1c10bc69e8 --- /dev/null +++ b/plugins/Realtime/cleanupchannels.php @@ -0,0 +1,71 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..')); + +$shortoptions = 'u'; +$longoptions = array('universe'); + +$helptext = <<selectAdd(); + $rc->selectAdd('channel_key'); + + $rc->whereAdd('modified < "' . common_sql_date(time() - Realtime_channel::TIMEOUT) . '"'); + + if ($rc->find()) { + $keys = $rc->fetchAll(); + + foreach ($keys as $key) { + $rc = Realtime_channel::staticGet('channel_key', $key); + if (!empty($rc)) { + printfv("Deleting realtime channel '$key'\n"); + $rc->delete(); + } + } + } +} + +if (have_option('u', 'universe')) { + $sn = new Status_network(); + if ($sn->find()) { + while ($sn->fetch()) { + $server = $sn->getServerName(); + StatusNet::init($server); + cleanupChannels(); + } + } +} else { + cleanupChannels(); +} -- 2.39.5