Example #1
0
 static function setupDB($dbhost, $dbuser, $dbpass, $dbname, $servers)
 {
     global $config;
     $config['db']['database_' . $dbname] = "mysqli://{$dbuser}:{$dbpass}@{$dbhost}/{$dbname}";
     $config['db']['ini_' . $dbname] = INSTALLDIR . '/classes/statusnet.ini';
     $config['db']['table_status_network'] = $dbname;
     self::$cache = new Memcache();
     if (is_array($servers)) {
         foreach ($servers as $server) {
             self::$cache->addServer($server);
         }
     } else {
         self::$cache->addServer($servers);
     }
     self::$base = $dbname;
 }
 /**
  * @param string $dbhost
  * @param string $dbuser
  * @param string $dbpass
  * @param string $dbname
  * @param array $servers memcached servers to use for caching config info
  */
 static function setupDB($dbhost, $dbuser, $dbpass, $dbname, $servers)
 {
     global $config;
     $config['db']['database_' . $dbname] = "mysqli://{$dbuser}:{$dbpass}@{$dbhost}/{$dbname}";
     $config['db']['ini_' . $dbname] = INSTALLDIR . '/classes/status_network.ini';
     $config['db']['table_status_network'] = $dbname;
     if (class_exists('Memcache')) {
         self::$cache = new Memcache();
         // If we're a parent command-line process we need
         // to be able to close out the connection after
         // forking, so disable persistence.
         //
         // We'll turn it back on again the second time
         // through which will either be in a child process,
         // or a single-process script which is switching
         // configurations.
         $persist = php_sapi_name() != 'cli' || self::$cacheInitialized;
         if (is_array($servers)) {
             foreach ($servers as $server) {
                 self::$cache->addServer($server, 11211, $persist);
             }
         } else {
             self::$cache->addServer($servers, 11211, $persist);
         }
         self::$cacheInitialized = true;
     }
     self::$base = $dbname;
 }
Example #3
0
 /**
  * Reconnect to the database for each child process,
  * or they'll get very confused trying to use the
  * same socket.
  */
 protected function resetDb()
 {
     // @fixme do we need to explicitly open the db too
     // or is this implied?
     global $_DB_DATAOBJECT;
     unset($_DB_DATAOBJECT['CONNECTIONS']);
     // Reconnect main memcached, or threads will stomp on
     // each other and corrupt their requests.
     $cache = Cache::instance();
     if ($cache) {
         $cache->reconnect();
     }
     // Also reconnect memcached for status_network table.
     if (!empty(Status_network::$cache)) {
         Status_network::$cache->close();
         Status_network::$cache = null;
     }
 }