/** * Creates or returns an instance of this class. * * @since 0.1.0 * @return Twitterbot A single instance of this class. */ public static function get_instance() { if (null === self::$single_instance) { self::$single_instance = new self(); } return self::$single_instance; }
die("Failed to acquire lock. Twitterbot may already be running.\n"); } // this bit guarantees that the process is 1) detached, and 2) independent echo 'Forking process into a daemon. Goodbye :)' . "\n"; if (pcntl_fork()) { exit; } posix_setsid(); if (pcntl_fork()) { exit; } // write the PIDs fwrite($fp, getmypid() . "\n"); fflush($fp); // start the loop $engine = new Twitterbot(); $engine->loop(); // reaching this point means an exit command has been issued flock($fp, LOCK_UN); fclose($fp); @unlink(TWITTERBOT_LOCKFILE); /** * Runs tests against the configuration of this bot, to make sure everything * is in working order. */ function test() { // test the database connection parameters echo "\n" . '==TESTING TWITTERBOT==' . "\n"; echo 'Testing MySQL connection...'; $db = @mysql_connect(DB_HOST, DB_USER, DB_PASS);