server(startup): make startup nullable; resolves #3721
This commit is contained in:
parent
cdd8eabcc0
commit
728adfe388
8 changed files with 43 additions and 14 deletions
|
@ -40,6 +40,7 @@ class Server extends Model
|
|||
protected $attributes = [
|
||||
'status' => self::STATUS_INSTALLING,
|
||||
'oom_disabled' => true,
|
||||
'startup' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -80,7 +81,7 @@ class Server extends Model
|
|||
'allocation_id' => 'required|bail|unique:servers|exists:allocations,id',
|
||||
'nest_id' => 'required|exists:nests,id',
|
||||
'egg_id' => 'required|exists:eggs,id',
|
||||
'startup' => 'required|string',
|
||||
'startup' => 'nullable|string',
|
||||
'skip_scripts' => 'sometimes|boolean',
|
||||
'image' => 'required|string|max:191',
|
||||
'database_limit' => 'present|nullable|integer|min:0',
|
||||
|
|
|
@ -49,7 +49,7 @@ class ServerConfigurationStructureService
|
|||
'uuid' => $server->uuid,
|
||||
'suspended' => $server->isSuspended(),
|
||||
'environment' => $this->environment->handle($server),
|
||||
'invocation' => $server->startup,
|
||||
'invocation' => !is_null($server->startup) ? $server->startup : $server->egg->startup,
|
||||
'skip_egg_scripts' => $server->skip_scripts,
|
||||
'build' => [
|
||||
'memory_limit' => $server->memory,
|
||||
|
@ -62,11 +62,6 @@ class ServerConfigurationStructureService
|
|||
],
|
||||
'container' => [
|
||||
'image' => $server->image,
|
||||
// This field is deprecated — use the value in the "build" block.
|
||||
//
|
||||
// TODO: remove this key in V2.
|
||||
'oom_disabled' => $server->oom_disabled,
|
||||
'requires_rebuild' => false,
|
||||
],
|
||||
'allocations' => [
|
||||
'default' => [
|
||||
|
|
|
@ -20,6 +20,6 @@ class StartupCommandService
|
|||
$replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]';
|
||||
}
|
||||
|
||||
return str_replace($find, $replace, $server->startup);
|
||||
return str_replace($find, $replace, !is_null($server->startup) ? $server->startup : $server->egg->startup);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class MakeStartupFieldNullableOnServersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->text('startup')->default(null)->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->text('startup')->change();
|
||||
});
|
||||
}
|
||||
}
|
|
@ -50,7 +50,7 @@ export interface Server extends Model {
|
|||
backups: number;
|
||||
};
|
||||
container: {
|
||||
startup: string;
|
||||
startup: string | null;
|
||||
image: string;
|
||||
environment: Record<string, string>;
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ export default (id: number, values: Partial<Values>, include: string[] = []): Pr
|
|||
http.patch(
|
||||
`/api/application/servers/${id}/startup`,
|
||||
{
|
||||
startup: values.startup,
|
||||
startup: values.startup !== '' ? values.startup : null,
|
||||
environment: values.environment,
|
||||
egg_id: values.eggId,
|
||||
image: values.image,
|
||||
|
|
|
@ -36,7 +36,7 @@ function InternalForm () {
|
|||
}
|
||||
|
||||
setFieldValue('eggId', egg.id);
|
||||
setFieldValue('startup', egg.startup);
|
||||
setFieldValue('startup', '');
|
||||
setFieldValue('image', egg.dockerImages.length > 0 ? egg.dockerImages[0] : '');
|
||||
}, [ egg ]);
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ function ServerStartupLineContainer ({ egg, server }: { egg: Egg | null; server:
|
|||
}
|
||||
|
||||
if (server.eggId === egg.id) {
|
||||
setFieldValue('startup', server.container.startup);
|
||||
setFieldValue('startup', server.container.startup || '');
|
||||
return;
|
||||
}
|
||||
|
||||
// Whenever the egg is changed, set the server's startup command to the egg's default.
|
||||
setFieldValue('startup', egg.startup);
|
||||
setFieldValue('startup', '');
|
||||
}, [ egg ]);
|
||||
|
||||
return (
|
||||
|
@ -46,6 +46,7 @@ function ServerStartupLineContainer ({ egg, server }: { egg: Egg | null; server:
|
|||
label={'Startup Command'}
|
||||
type={'text'}
|
||||
description={'Edit your server\'s startup command here. The following variables are available by default: {{SERVER_MEMORY}}, {{SERVER_IP}}, and {{SERVER_PORT}}.'}
|
||||
placeholder={egg?.startup || ''}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
@ -212,7 +213,7 @@ export default () => {
|
|||
<Formik
|
||||
onSubmit={submit}
|
||||
initialValues={{
|
||||
startup: server.container.startup,
|
||||
startup: server.container.startup || '',
|
||||
environment: [] as Record<string, any>,
|
||||
image: server.container.image,
|
||||
eggId: server.eggId,
|
||||
|
|
Loading…
Reference in a new issue