2017-07-23 19:51:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Services\Servers;
|
|
|
|
|
2017-08-05 22:26:30 +00:00
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
use GuzzleHttp\Exception\RequestException;
|
2018-01-06 00:27:47 +00:00
|
|
|
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
|
|
|
use Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface;
|
2017-07-23 19:51:18 +00:00
|
|
|
|
|
|
|
class ContainerRebuildService
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
|
|
|
*/
|
2018-01-06 00:27:47 +00:00
|
|
|
private $repository;
|
2017-07-24 00:57:43 +00:00
|
|
|
|
2017-07-23 19:51:18 +00:00
|
|
|
/**
|
|
|
|
* ContainerRebuildService constructor.
|
|
|
|
*
|
2018-01-06 00:27:47 +00:00
|
|
|
* @param \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface $repository
|
2017-07-23 19:51:18 +00:00
|
|
|
*/
|
2018-01-06 00:27:47 +00:00
|
|
|
public function __construct(ServerRepositoryInterface $repository)
|
|
|
|
{
|
2017-07-23 19:51:18 +00:00
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark a server for rebuild on next boot cycle.
|
|
|
|
*
|
2018-01-06 00:27:47 +00:00
|
|
|
* @param \Pterodactyl\Models\Server $server
|
2017-07-23 19:51:18 +00:00
|
|
|
*
|
2018-01-06 00:27:47 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
2017-07-23 19:51:18 +00:00
|
|
|
*/
|
2018-01-06 00:27:47 +00:00
|
|
|
public function handle(Server $server)
|
2017-07-23 19:51:18 +00:00
|
|
|
{
|
|
|
|
try {
|
2018-01-06 00:27:47 +00:00
|
|
|
$this->repository->setServer($server)->rebuild();
|
2017-07-23 19:51:18 +00:00
|
|
|
} catch (RequestException $exception) {
|
2018-01-06 00:27:47 +00:00
|
|
|
throw new DaemonConnectionException($exception);
|
2017-07-23 19:51:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|