初始化本地仓库
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: http://www.madong.tech
|
||||
*/
|
||||
|
||||
namespace core\scheduler\event;
|
||||
|
||||
use app\enum\system\OperationResult;
|
||||
use core\scheduler\event\EventBootstrap;
|
||||
|
||||
class UrlTask implements EventBootstrap
|
||||
{
|
||||
/**
|
||||
* @param $crontab
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function parse($crontab): array
|
||||
{
|
||||
$url = trim($crontab['target'] ?? '');
|
||||
$code = OperationResult::SUCCESS->value;
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$response = $client->get($url);
|
||||
$log = strip_tags($response->getBody()->getContents());
|
||||
} catch (\Throwable $throwable) {
|
||||
$code = OperationResult::FAILURE->value;
|
||||
$log = $throwable->getMessage();
|
||||
}
|
||||
return ['code' => $code, 'log' => $log];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user