Ejemplo n.º 1
0
Archivo: Db.php Proyecto: miaokuan/wee
 protected function connect($force = false)
 {
     if ($force || !$this->isConnected) {
         $config = $this->config;
         $port = empty($config['port']) ? 3306 : $config['port'];
         $charset = empty($config['charset']) ? 'utf8' : $config['charset'];
         $socket = null;
         $flag = null;
         if (isset($config['flag'])) {
             $flag = $config['flag'];
         }
         $this->isConnected = $this->mysqli->real_connect($config['host'], $config['user'], $config['password'], $config['database'], $port, $socket, $flag);
         if (!$this->isConnected) {
             Log::fatal('db connect error. [errno:' . mysqli_connect_errno() . ' error:' . mysqli_connect_error() . ']');
         } else {
             $this->mysqli->set_charset($charset);
         }
     }
     return $this->isConnected;
 }
Ejemplo n.º 2
0
Archivo: App.php Proyecto: miaokuan/wee
 protected function initpid()
 {
     $pidfile = VAR_DIR . '/pid/' . $this->sign . '_' . $this->mypid . '.pid';
     if (file_put_contents($pidfile, $this->mypid)) {
         $this->pidfile = $pidfile;
     } else {
         Log::fatal("Unable to write pid to " . $pidfile);
         exit;
     }
     $pidfiles = glob(VAR_DIR . '/pid/' . $this->sign . "*.pid");
     if (is_array($pidfiles) && count($pidfiles) > $this->concurrent) {
         $text = "pid file(" . $pidfiles[0] . ") existed.";
         Log::fatal($text);
         exit;
     }
 }