work 777 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env php
  2. <?php
  3. use app\common\model\Mobile;
  4. use think\App;
  5. define('APP_PATH', __DIR__ . '/application/');
  6. bcscale(2);
  7. // 加载框架引导文件
  8. require __DIR__.'/thinkphp/base.php';
  9. App::initCommon();
  10. $work=new \Workerman\Worker();
  11. $work->onWorkerStart=function ($conn){
  12. while (true){
  13. $ids=Mobile::where('activity_time_end','<=',time())
  14. ->where('is_activity',1)
  15. ->where('type',1)
  16. ->column('id');
  17. user_log('mobileActivityExpired',"找到".count($ids).'条记录');
  18. foreach ($ids as $id){
  19. $mobile=Mobile::find($id);
  20. $mobile->makeNotActivity();
  21. }
  22. sleep(3);
  23. }
  24. };
  25. $work->onWorkerStop=function (\Workerman\Worker $work){
  26. var_dump('close');
  27. };
  28. $work->run();