function onStart(\swoole_server $serv, $worker_id) { $this->redis = new \redis(); $this->redis->connect('localhost'); $this->today = date("Y-m-d"); $this->log_table = 'logs_' . $this->today; $this->tomorrow = date("Y-m-d", time() + 86400); \Swoole::$php->db->query("CREATE TABLE IF NOT EXISTS `logs_" . $this->today . "` LIKE `logs`"); \Swoole::$php->db->query("CREATE TABLE IF NOT EXISTS `logs_" . $this->tomorrow . "` LIKE `logs`"); //每个worker 24小时执行一次创建表 不要零点启动服务 $serv->addtimer(24 * 60 * 60000); }