diff --git a/application/command.php b/application/command.php new file mode 100644 index 0000000..7cb49f0 --- /dev/null +++ b/application/command.php @@ -0,0 +1,4 @@ + 'app\common\command\ProjectReport', +]; diff --git a/application/common/Plugins/GateWayWorker/crontab.php b/application/common/Plugins/GateWayWorker/crontab.php new file mode 100644 index 0000000..b35e982 --- /dev/null +++ b/application/common/Plugins/GateWayWorker/crontab.php @@ -0,0 +1,40 @@ +name = 'crontab'; +$doneTicket = []; +$task->onWorkerStart = function ($task) { + $timerId = Timer::add(1, 'checkTime'); +}; + +// 运行worker +Worker::runAll(); + +function checkTime() +{ + global $doneTicket; + $now = time(); + $dateTime = date('H:i', $now); + //每天23:55统计项目情况 + if ($dateTime == '23:55' && (!isset($doneTicket['setProjectReportDate']) || date('Y-m-d', $now) != $doneTicket['setProjectReportDate'])) { + setProjectReport(); + } +} + +function setProjectReport() +{ + global $doneTicket; + $doneTicket['setProjectReportDate'] = date('Y-m-d', time()); + exec("php think projectReport",$out); + echo $out[0]; +} + diff --git a/application/common/command/ProjectReport.php b/application/common/command/ProjectReport.php new file mode 100644 index 0000000..b974ed0 --- /dev/null +++ b/application/common/command/ProjectReport.php @@ -0,0 +1,21 @@ +setName('ProjectReport'); + } + + protected function execute(Input $input, Output $output) + { + \app\common\Model\ProjectReport::setDayilyProejctReport(); + $output->writeln('success_at ' . nowTime()); + } +} diff --git a/crontab.bat b/crontab.bat new file mode 100644 index 0000000..22c8801 --- /dev/null +++ b/crontab.bat @@ -0,0 +1 @@ +php application\common\Plugins\GateWayWorker\crontab.php diff --git a/crontab.sh b/crontab.sh new file mode 100644 index 0000000..01deb66 --- /dev/null +++ b/crontab.sh @@ -0,0 +1,2 @@ +#!/bin/bash +php application/common/Plugins/GateWayWorker/crontab.php start& diff --git a/crontab_stop.sh b/crontab_stop.sh new file mode 100644 index 0000000..0960ea1 --- /dev/null +++ b/crontab_stop.sh @@ -0,0 +1,2 @@ +#!/bin/bash +php application/common/Plugins/GateWayWorker/crontab.php stop&