123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- namespace catcher\library\crontab;
- trait Store
- {
-
- public function storeMasterPid($pid)
- {
- $path = $this->getMasterPidPath();
- return file_put_contents($path, $pid);
- }
-
- protected function unsetWorkerStatus($pid)
- {
- $this->table->del($this->getColumnKey($pid));
- }
-
- public function output()
- {
-
- sleep(1);
- return $this->getProcessStatusInfo();
- }
-
- public function getMasterPid()
- {
- $pid = file_get_contents($this->getMasterPidPath());
- return intval($pid);
- }
-
- protected function getMasterPidPath()
- {
- return config('catch.schedule.master_pid_file');
- }
-
- protected function schedulePath()
- {
- $path = config('catch.schedule.store_path');
- if (!is_dir($path)) {
- mkdir($path, 0777, true);
- }
- return $path;
- }
-
- protected function getSaveProcessStatusFile()
- {
- return $this->schedulePath() . '.worker-status';
- }
-
- protected function saveProcessStatus()
- {
- file_put_contents($this->getSaveProcessStatusFile(), $this->renderProcessesStatusToString());
- }
-
- protected function getProcessStatusInfo()
- {
- return file_get_contents($this->getSaveProcessStatusFile());
- }
- }
|