work 902 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env php
  2. <?php
  3. use think\App;
  4. use Workerman\Worker as WO;
  5. define('APP_PATH', __DIR__ . '/application/');
  6. bcscale(2);
  7. // 加载框架引导文件
  8. require __DIR__.'/thinkphp/base.php';
  9. App::initCommon();
  10. WO::$logFile=sprintf('%s/workerman.log',RUNTIME_PATH);
  11. WO::$pidFile=sprintf('%s/workerman.pid',RUNTIME_PATH);
  12. WO::$processTitle='beauty-no';
  13. abstract class Com{
  14. protected static function log($data){
  15. user_log('commands/'.class_basename(get_called_class()),$data);
  16. }
  17. protected static function logError(\Exception $exception){
  18. user_log('commands/'.class_basename(get_called_class()),[
  19. 'exception'=>$exception->getMessage(),
  20. 'file'=>$exception->getFile().' line:'.$exception->getLine(),
  21. 'trace'=>$exception->getTrace()
  22. ]);
  23. }
  24. }
  25. foreach (glob(__DIR__.'/commands/*.php') as $file){
  26. require $file;
  27. }
  28. WO::runAll();