@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | public static function getGlobalTimerCacheKey() |
94 | 94 | { |
95 | - return 'laravels:timer:' . strtolower(self::$globalTimerLockKey); |
|
95 | + return 'laravels:timer:'.strtolower(self::$globalTimerLockKey); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | public static function getGlobalTimerLock() |
@@ -105,21 +105,21 @@ discard block |
||
105 | 105 | $expire = self::GLOBAL_TIMER_LOCK_SECONDS; |
106 | 106 | $result = $redis->set($key, $value, 'ex', $expire, 'nx'); |
107 | 107 | // Compatible with Predis and PhpRedis |
108 | - return $result === true || ((string)$result === 'OK'); |
|
108 | + return $result === true || ((string) $result === 'OK'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | public static function isGlobalTimerAlive() |
112 | 112 | { |
113 | 113 | /**@var \Illuminate\Redis\Connections\PhpRedisConnection $redis */ |
114 | 114 | $redis = app('redis'); |
115 | - return (bool)$redis->exists(self::getGlobalTimerCacheKey()); |
|
115 | + return (bool) $redis->exists(self::getGlobalTimerCacheKey()); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public static function renewGlobalTimerLock($expire) |
119 | 119 | { |
120 | 120 | /**@var \Illuminate\Redis\Connections\PhpRedisConnection $redis */ |
121 | 121 | $redis = app('redis'); |
122 | - return (bool)$redis->expire(self::getGlobalTimerCacheKey(), $expire); |
|
122 | + return (bool) $redis->expire(self::getGlobalTimerCacheKey(), $expire); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | public static function setGlobalTimerLockKey($lockKey) |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | public static function setEnable($enable) |
131 | 131 | { |
132 | - self::$enable = (bool)$enable; |
|
132 | + self::$enable = (bool) $enable; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | public static function isEnable() |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | $config['jobs'][] = CheckGlobalTimerAliveCronJob::class; |
25 | 25 | } |
26 | 26 | |
27 | - $callback = function (Process $process) use ($swoole, $config, $laravelConfig) { |
|
28 | - $pidfile = dirname($swoole->setting['pid_file']) . '/' . $this->timerPidFile; |
|
27 | + $callback = function(Process $process) use ($swoole, $config, $laravelConfig) { |
|
28 | + $pidfile = dirname($swoole->setting['pid_file']).'/'.$this->timerPidFile; |
|
29 | 29 | file_put_contents($pidfile, $process->pid); |
30 | 30 | $this->setProcessTitle(sprintf('%s laravels: timer process', $config['process_prefix'])); |
31 | 31 | $this->initLaravel($laravelConfig, $swoole); |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | |
40 | 40 | $timerIds = $this->registerTimers($config['jobs']); |
41 | 41 | |
42 | - Process::signal(SIGUSR1, function ($signo) use ($config, $timerIds, $process) { |
|
42 | + Process::signal(SIGUSR1, function($signo) use ($config, $timerIds, $process) { |
|
43 | 43 | foreach ($timerIds as $timerId) { |
44 | 44 | if (Timer::exists($timerId)) { |
45 | 45 | Timer::clear($timerId); |
46 | 46 | } |
47 | 47 | } |
48 | - Timer::after($config['max_wait_time'] * 1000, function () use ($process) { |
|
48 | + Timer::after($config['max_wait_time'] * 1000, function() use ($process) { |
|
49 | 49 | $process->exit(0); |
50 | 50 | }); |
51 | 51 | }); |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | if (empty($job->interval())) { |
77 | 77 | throw new \InvalidArgumentException(sprintf('The interval of %s cannot be empty', get_class($job))); |
78 | 78 | } |
79 | - $runJob = function () use ($job) { |
|
80 | - $runCallback = function () use ($job) { |
|
81 | - $this->callWithCatchException(function () use ($job) { |
|
79 | + $runJob = function() use ($job) { |
|
80 | + $runCallback = function() use ($job) { |
|
81 | + $this->callWithCatchException(function() use ($job) { |
|
82 | 82 | if (($job instanceof CheckGlobalTimerAliveCronJob) || $job::isEnable()) { |
83 | 83 | $job->run(); |
84 | 84 | } |