BSC丨Solana丨AVAX丨LUNA公链游戏系统开发规则丨链游系统开发(结构模型)模式结构:protectedstaticfunctionmonitorWorkersForWindows(){Timer::add(1,"\Workerman\Worker::checkWorkerStatusForWindows");static::$globalEvent->loop();}/*Exitcurrentprocess.@returnvoid/protectedstaticfunctionexitAndClearAll(){foreach(static::$_workersas$worker){$socket_name=$worker->getSocketName();if($worker->transport==='unix'&&$socket_name){list(,$address)=explode(':',$socket_name,2);@unlink($address);}}@unlink(static::$pidFile);static::log("Workerman[".basename(static::$_startFile)."]hasbeenstopped");if(static::$onMasterStop){call_user_func(static::$onMasterStop);}exit(0);}/**Executereload.*@returnvoid/protectedstaticfunctionreload(){//Formasterprocess.if(static::$_masterPid===posix_getpid()){//Setreloadingstate.if(static::$_status!==static::STATUS_RELOADING&&static::$_status!==static::STATUS_SHUTDOWN){static::log("Workerman[".basename(static::$_startFile)."]reloading");static::$_status=static::STATUS_RELOADING;//TrytoemitonMasterReloadcallback.if(static::$onMasterReload){try{call_user_func(static::$onMasterReload);}catch(\Exception$e){static::log($e);exit(250);}catch(\Error$e){static::log($e);exit(250);}static::initId();}}if(static::$_gracefulStop){$sig=SIGQUIT;}else{$sig=SIGUSR1;}//Sendreloadsignaltoallchildprocesses.$reloadable_pid_array=array();foreach(static::$_pidMapas$worker_id=>$worker_pid_array){$worker=static::$_workers[$worker_id];if($worker->reloadable){foreach($worker_pid_arrayas$pid){$reloadable_pid_array[$pid]=$pid;}}else{foreach($worker_pid_arrayas$pid){//Sendreloadsignaltoaworkerprocesswhichreloadableisfalse.posix_kill($pid,$sig);}}}//Getallpidsthatarewaitingreload.static::$_pidsToRestart=array_intersect(static::$_pidsToRestart,$reloadable_pid_array);//Reloadcomplete.if(empty(static::$_pidsToRestart)){if(static::$_status!==static::STATUS_SHUTDOWN){static::$_status=static::STATUS_RUNNING;}return;}//Continuereload.$one_worker_pid=current(static::$_pidsToRestart);//Sendreloadsignaltoaworkerprocess.posix_kill($one_worker_pid,$sig);//Iftheprocessdoesnotexitafterstatic::KILL_WORKER_TIMER_TIMEsecondstrytokillit.if(!static::$_gracefulStop){Timer::add(static::KILL_WORKER_TIMER_TIME,'posix_kill',array($one_worker_pid,SIGKILL),false);}}//Forchildprocesses.else{reset(static::$_workers);$worker=current(static::$_workers);//TrytoemitonWorkerReloadcallback.if($worker->onWorkerReload){try{call_user_func($worker->onWorkerReload,$worker);}catch(\Exception$e){static::log($e);exit(250);}catch(\Error$e){static::log($e);exit(250);}}if($worker->reloadable){static::stopAll();}}}