Remove suspended & installing fields, replace with single status field

This commit is contained in:
Dane Everitt 2021-01-17 15:51:56 -08:00
parent 4c29be2e54
commit a75a347d65
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
24 changed files with 115 additions and 59 deletions

View file

@ -44,7 +44,7 @@ class ReinstallServerService
public function handle(Server $server)
{
return $this->connection->transaction(function () use ($server) {
$server->forceFill(['installed' => Server::STATUS_INSTALLING])->save();
$server->fill(['status' => Server::STATUS_INSTALLING])->save();
$this->daemonServerRepository->setServer($server)->reinstall();

View file

@ -60,7 +60,7 @@ class ServerConfigurationStructureService
{
return [
'uuid' => $server->uuid,
'suspended' => $server->suspended,
'suspended' => $server->isSuspended(),
'environment' => $this->environment->handle($server),
'invocation' => $server->startup,
'skip_egg_scripts' => $server->skip_scripts,
@ -137,7 +137,7 @@ class ServerConfigurationStructureService
'skip_scripts' => $server->skip_scripts,
],
'rebuild' => false,
'suspended' => (int)$server->suspended,
'suspended' => $server->isSuspended() ? 1 : 0,
];
}
}

View file

@ -229,8 +229,8 @@ class ServerCreationService
'node_id' => Arr::get($data, 'node_id'),
'name' => Arr::get($data, 'name'),
'description' => Arr::get($data, 'description') ?? '',
'status' => Server::STATUS_INSTALLING,
'skip_scripts' => Arr::get($data, 'skip_scripts') ?? isset($data['skip_scripts']),
'suspended' => false,
'owner_id' => Arr::get($data, 'owner_id'),
'memory' => Arr::get($data, 'memory'),
'swap' => Arr::get($data, 'swap'),

View file

@ -6,7 +6,6 @@ use Webmozart\Assert\Assert;
use Pterodactyl\Models\Server;
use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
use Pterodactyl\Exceptions\Http\Server\ServerTransferringException;
class SuspensionService
@ -54,7 +53,7 @@ class SuspensionService
// Nothing needs to happen if we're suspending the server and it is already
// suspended in the database. Additionally, nothing needs to happen if the server
// is not suspended and we try to un-suspend the instance.
if ($isSuspending === $server->suspended) {
if ($isSuspending === $server->isSuspended()) {
return;
}
@ -63,9 +62,9 @@ class SuspensionService
throw new ServerTransferringException;
}
$this->connection->transaction(function () use ($action, $server) {
$this->connection->transaction(function () use ($action, $server, $isSuspending) {
$server->update([
'suspended' => $action === self::ACTION_SUSPEND,
'status' => $isSuspending ? Server::STATUS_SUSPENDED : null,
]);
// Only send the suspension request to wings if the server is not currently being transferred.