Skip to content

Commit fc20af9

Browse files
authored
fixes: cron基类 缓存文件地址无法自定义; try捕获范围增加
1 parent 0a8ea33 commit fc20af9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/siam/AbstractInterface/CronBase.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ abstract class CronBase
1919
*/
2020
public function __construct()
2121
{
22-
static::$runtimePath = dirname(__FILE__);
22+
if(empty(static::$runtimePath)) static::$runtimePath = dirname(__FILE__);
2323
// 判断是否为单一任务 是的话停止运行
24-
$lockName = static::$runtimePath.DIRECTORY_SEPARATOR.md5($this->rule()).".txt";
24+
$lockName = static::$runtimePath.DIRECTORY_SEPARATOR.$this->rule().".txt";
2525
if ( static::$singleCron && file_exists($lockName) ){
2626
throw new \Exception($this->rule() . " is single cron job");
2727
}
@@ -42,9 +42,8 @@ abstract function rule();
4242
* @throws \Throwable
4343
*/
4444
public function run(){
45-
$data = $this->before();
46-
4745
try{
46+
$data = $this->before();
4847
$res = $this->do($data);
4948
}catch (\Throwable $throwable){
5049
$this->clearClock();
@@ -74,9 +73,9 @@ abstract function after($res = true);
7473

7574
private function clearClock()
7675
{
77-
$lockName = static::$runtimePath.DIRECTORY_SEPARATOR.md5($this->rule()).".txt";
76+
$lockName = static::$runtimePath.DIRECTORY_SEPARATOR.$this->rule().".txt";
7877
if (file_exists($lockName)){
7978
unlink($lockName);
8079
}
8180
}
82-
}
81+
}

0 commit comments

Comments
 (0)