使用 php server.php start -d 启动失败
报错 Undefined index: app_path
使用php think worker:server 启动成功
定时器也执行成功了
但是不一会cpu直接爆满了 有哪位大佬知道是什么原因吗 是有禁用函数没有启动吗
<?php
namespace app\push\controller;
use Workerman\Lib\Timer;
use app\admin\controller\Weibo;
class MyTimer{
protected $timer_time = 1;
public function add_timer(){
Timer::add($this->timer_time, array($this, 'index'), array(), true);
}
//执行方法
public function index(){
$ti = cache('weibods');
foreach ($ti as $key => $value) {
$tim[$key]=mktime($value['htime'],$value['itime'],$value['stime'],date('m'),date('d'),date('Y'));
}
$time = time();//现在时间戳
foreach ($tim as $ki => $val) {
if($time === $val){
$wb = new weibo();
$wb->tophots();
$site = "\n".date('Y-m-d H:i:s',time());
file_put_contents('shiq.txt', $site.'执行了一次定时任务。\n',FILE_APPEND | LOCK_EX);
}
}
}
}
最佳答案
