From e856af34c3ac560a21286ca89019c2249994c080 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 9 Feb 2010 12:39:31 -0800 Subject: Configurable delay between queuedaemon.php spawns/respawns to help stagger out startups and subscriptions. Defaults to 1 second. $config['queue']['spawndelay'] = 1; --- lib/default.php | 1 + lib/spawningdaemon.php | 2 ++ 2 files changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/default.php b/lib/default.php index 485a08ba4..bf4b83718 100644 --- a/lib/default.php +++ b/lib/default.php @@ -88,6 +88,7 @@ $default = 'stomp_manual_failover' => true, // if multiple servers are listed, treat them as separate (enqueue on one randomly, listen on all) 'monitor' => null, // URL to monitor ping endpoint (work in progress) 'softlimit' => '90%', // total size or % of memory_limit at which to restart queue threads gracefully + 'spawndelay' => 1, // Wait at least N seconds between (re)spawns of child processes to avoid slamming the queue server with subscription startup 'debug_memory' => false, // true to spit memory usage to log 'inboxes' => true, // true to do inbox distribution & output queueing from in background via 'distrib' queue ), diff --git a/lib/spawningdaemon.php b/lib/spawningdaemon.php index b1961d688..862cbb4fa 100644 --- a/lib/spawningdaemon.php +++ b/lib/spawningdaemon.php @@ -83,6 +83,7 @@ abstract class SpawningDaemon extends Daemon $this->log(LOG_INFO, "Spawned thread $i as pid $pid"); $children[$i] = $pid; } + sleep(common_config('queue', 'spawndelay')); } $this->log(LOG_INFO, "Waiting for children to complete."); @@ -111,6 +112,7 @@ abstract class SpawningDaemon extends Daemon $this->log(LOG_INFO, "Respawned thread $i as pid $pid"); $children[$i] = $pid; } + sleep(common_config('queue', 'spawndelay')); } else { $this->log(LOG_INFO, "Thread $i pid $pid exited with status $exitCode; closing out thread."); } -- cgit v1.2.3-54-g00ecf From d9c9b2a12fe6cbb800440eeb0174d375760e0103 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 10 Feb 2010 10:59:30 -0800 Subject: Queue daemon fixes: * skip unnecessary unsubscribes on graceful shutdown -- takes a long time for many queues, slows down our restarts when hitting graceful mem limit * fix control channel (was broken when we switched to support multiple queue servers) --- lib/stompqueuemanager.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php index 6730cd213..cc4c817d8 100644 --- a/lib/stompqueuemanager.php +++ b/lib/stompqueuemanager.php @@ -107,9 +107,10 @@ class StompQueueManager extends QueueManager $message .= ':' . $param; } $this->_connect(); - $result = $this->_send($this->control, - $message, - array ('created' => common_sql_now())); + $con = $this->cons[$this->defaultIdx]; + $result = $con->send($this->control, + $message, + array ('created' => common_sql_now())); if ($result) { $this->_log(LOG_INFO, "Sent control ping to queue daemons: $message"); return true; @@ -368,17 +369,10 @@ class StompQueueManager extends QueueManager foreach ($this->cons as $i => $con) { if ($con) { $this->rollback($i); - $con->unsubscribe($this->control); + $con->disconnect(); + $this->cons[$i] = null; } } - if ($this->sites) { - foreach ($this->sites as $server) { - StatusNet::init($server); - $this->doUnsubscribe(); - } - } else { - $this->doUnsubscribe(); - } return true; } -- cgit v1.2.3-54-g00ecf