More testing. Removed Gitea actions.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -54,8 +54,7 @@ class CommandBackup extends Command
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$rclone = new Rclone((string)$app->getConfig('rclone.path'));
|
||||
$rclone->setLogger($app->getLogger()->withName('rclone'));
|
||||
$rclone = new Rclone($app->getLogger()->withName('rclone'), (string)$app->getConfig('rclone.path'));
|
||||
|
||||
$notification = new Notification();
|
||||
/** @var array<array-key,array<string,string>> */
|
||||
|
@ -4,8 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Rclone;
|
||||
|
||||
use Psr\Log\LoggerAwareTrait;
|
||||
use Psr\Log\NullLogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
@ -20,7 +18,10 @@ use Exception;
|
||||
*/
|
||||
class Rclone
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
/**
|
||||
* The logger instance.
|
||||
*/
|
||||
protected LoggerInterface $logger;
|
||||
|
||||
protected string $rclonePath;
|
||||
/**
|
||||
@ -40,10 +41,10 @@ class Rclone
|
||||
*
|
||||
* @param string $rclonePath Relative or absolute path
|
||||
*/
|
||||
public function __construct(string $rclonePath = "rclone")
|
||||
public function __construct(LoggerInterface $logger, string $rclonePath = "rclone")
|
||||
{
|
||||
$this->rclonePath = $rclonePath;
|
||||
$this->setLogger(new NullLogger());
|
||||
$this->logger = $logger;
|
||||
|
||||
$process = $this->exec('--version');
|
||||
if (!$process->isSuccessful()) {
|
||||
@ -130,22 +131,18 @@ class Rclone
|
||||
$options
|
||||
)
|
||||
);
|
||||
if ($this->logger instanceof LoggerInterface) {
|
||||
$this->logger->info("Execute command", [$process->getCommandLine()]);
|
||||
}
|
||||
|
||||
$this->logger->info("Execute command", [$process->getCommandLine()]);
|
||||
|
||||
|
||||
$process->setTimeout(4 * 3600);
|
||||
$process->run();
|
||||
|
||||
// executes after the command finishes
|
||||
if (!$process->isSuccessful()) {
|
||||
if ($this->logger instanceof LoggerInterface) {
|
||||
$this->logger->error("Failed execution");
|
||||
}
|
||||
}
|
||||
if ($this->logger instanceof LoggerInterface) {
|
||||
$this->logger->info("Return code", [$process->getExitCode()]);
|
||||
$this->logger->error("Failed execution");
|
||||
}
|
||||
$this->logger->info("Return code", [$process->getExitCode()]);
|
||||
return $process;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user