/** * @CliPlugin One * @CliPlugin Crontab */ public function main(zCallable $function, $input, $output) { $args = $function->getOne('one,crontab')->getArgs(); $lock = File::generateFilePath('lock', $function->getName()); if (!empty($args)) { $lock = $args[0]; } if (filesize($lock) > 0) { $pid = trim(file_get_contents($lock)); if (posix_getsid($pid) !== false) { throw new RuntimeException("Process {$function->getName()}() is still running"); } } File::write($lock, getmypid()); }
public function __call($name, array $arguments) { $strid = serialize($arguments); $files = []; $args = []; if (is_array($arguments[0])) { $files = $arguments[0]; } else { $files = $arguments; } if (count($arguments) == 2 && is_array($arguments[1])) { $args = $arguments[1]; } return $this->build($name, File::generateFilePath('build', $name, $strid), $files, $args); }