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;
|
2019-11-25 04:19:31 +00:00
|
|
|
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
2018-01-06 00:27:47 +00:00
|
|
|
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
2017-07-23 19:51:18 +00:00
|
|
|
|
|
|
|
class ContainerRebuildService
|
|
|
|
{
|
|
|
|
/**
|
2019-11-25 04:19:31 +00:00
|
|
|
* @var \Pterodactyl\Repositories\Wings\DaemonServerRepository
|
2017-07-23 19:51:18 +00:00
|
|
|
*/
|
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.
|
|
|
|
*
|
2019-11-25 04:19:31 +00:00
|
|
|
* @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $repository
|
2017-07-23 19:51:18 +00:00
|
|
|
*/
|
2019-11-25 04:19:31 +00:00
|
|
|
public function __construct(DaemonServerRepository $repository)
|
2018-01-06 00:27:47 +00:00
|
|
|
{
|
2017-07-23 19:51:18 +00:00
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-11-25 04:19:31 +00:00
|
|
|
* Mark a server for rebuild on next boot cycle. This just makes an empty patch
|
|
|
|
* request to Wings which will automatically mark the container as requiring a rebuild
|
|
|
|
* on the next boot as a result.
|
2017-07-23 19:51:18 +00:00
|
|
|
*
|
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 {
|
2019-11-25 04:19:31 +00:00
|
|
|
$this->repository->setServer($server)->update([]);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|