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 = [
|
protected $attributes = [
|
||||||
'status' => self::STATUS_INSTALLING,
|
'status' => self::STATUS_INSTALLING,
|
||||||
'oom_disabled' => true,
|
'oom_disabled' => true,
|
||||||
|
'startup' => null,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +81,7 @@ class Server extends Model
|
||||||
'allocation_id' => 'required|bail|unique:servers|exists:allocations,id',
|
'allocation_id' => 'required|bail|unique:servers|exists:allocations,id',
|
||||||
'nest_id' => 'required|exists:nests,id',
|
'nest_id' => 'required|exists:nests,id',
|
||||||
'egg_id' => 'required|exists:eggs,id',
|
'egg_id' => 'required|exists:eggs,id',
|
||||||
'startup' => 'required|string',
|
'startup' => 'nullable|string',
|
||||||
'skip_scripts' => 'sometimes|boolean',
|
'skip_scripts' => 'sometimes|boolean',
|
||||||
'image' => 'required|string|max:191',
|
'image' => 'required|string|max:191',
|
||||||
'database_limit' => 'present|nullable|integer|min:0',
|
'database_limit' => 'present|nullable|integer|min:0',
|
||||||
|
|
|
@ -49,7 +49,7 @@ class ServerConfigurationStructureService
|
||||||
'uuid' => $server->uuid,
|
'uuid' => $server->uuid,
|
||||||
'suspended' => $server->isSuspended(),
|
'suspended' => $server->isSuspended(),
|
||||||
'environment' => $this->environment->handle($server),
|
'environment' => $this->environment->handle($server),
|
||||||
'invocation' => $server->startup,
|
'invocation' => !is_null($server->startup) ? $server->startup : $server->egg->startup,
|
||||||
'skip_egg_scripts' => $server->skip_scripts,
|
'skip_egg_scripts' => $server->skip_scripts,
|
||||||
'build' => [
|
'build' => [
|
||||||
'memory_limit' => $server->memory,
|
'memory_limit' => $server->memory,
|
||||||
|
@ -62,11 +62,6 @@ class ServerConfigurationStructureService
|
||||||
],
|
],
|
||||||
'container' => [
|
'container' => [
|
||||||
'image' => $server->image,
|
'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' => [
|
'allocations' => [
|
||||||
'default' => [
|
'default' => [
|
||||||
|
|
|
@ -20,6 +20,6 @@ class StartupCommandService
|
||||||
$replace[] = ($variable->user_viewable && !$hideAllValues) ? ($variable->server_value ?? $variable->default_value) : '[hidden]';
|
$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;
|
backups: number;
|
||||||
};
|
};
|
||||||
container: {
|
container: {
|
||||||
startup: string;
|
startup: string | null;
|
||||||
image: string;
|
image: string;
|
||||||
environment: Record<string, string>;
|
environment: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ export default (id: number, values: Partial<Values>, include: string[] = []): Pr
|
||||||
http.patch(
|
http.patch(
|
||||||
`/api/application/servers/${id}/startup`,
|
`/api/application/servers/${id}/startup`,
|
||||||
{
|
{
|
||||||
startup: values.startup,
|
startup: values.startup !== '' ? values.startup : null,
|
||||||
environment: values.environment,
|
environment: values.environment,
|
||||||
egg_id: values.eggId,
|
egg_id: values.eggId,
|
||||||
image: values.image,
|
image: values.image,
|
||||||
|
|
|
@ -36,7 +36,7 @@ function InternalForm () {
|
||||||
}
|
}
|
||||||
|
|
||||||
setFieldValue('eggId', egg.id);
|
setFieldValue('eggId', egg.id);
|
||||||
setFieldValue('startup', egg.startup);
|
setFieldValue('startup', '');
|
||||||
setFieldValue('image', egg.dockerImages.length > 0 ? egg.dockerImages[0] : '');
|
setFieldValue('image', egg.dockerImages.length > 0 ? egg.dockerImages[0] : '');
|
||||||
}, [ egg ]);
|
}, [ egg ]);
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,12 @@ function ServerStartupLineContainer ({ egg, server }: { egg: Egg | null; server:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.eggId === egg.id) {
|
if (server.eggId === egg.id) {
|
||||||
setFieldValue('startup', server.container.startup);
|
setFieldValue('startup', server.container.startup || '');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whenever the egg is changed, set the server's startup command to the egg's default.
|
// Whenever the egg is changed, set the server's startup command to the egg's default.
|
||||||
setFieldValue('startup', egg.startup);
|
setFieldValue('startup', '');
|
||||||
}, [ egg ]);
|
}, [ egg ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -46,6 +46,7 @@ function ServerStartupLineContainer ({ egg, server }: { egg: Egg | null; server:
|
||||||
label={'Startup Command'}
|
label={'Startup Command'}
|
||||||
type={'text'}
|
type={'text'}
|
||||||
description={'Edit your server\'s startup command here. The following variables are available by default: {{SERVER_MEMORY}}, {{SERVER_IP}}, and {{SERVER_PORT}}.'}
|
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>
|
</div>
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ export default () => {
|
||||||
<Formik
|
<Formik
|
||||||
onSubmit={submit}
|
onSubmit={submit}
|
||||||
initialValues={{
|
initialValues={{
|
||||||
startup: server.container.startup,
|
startup: server.container.startup || '',
|
||||||
environment: [] as Record<string, any>,
|
environment: [] as Record<string, any>,
|
||||||
image: server.container.image,
|
image: server.container.image,
|
||||||
eggId: server.eggId,
|
eggId: server.eggId,
|
||||||
|
|
Loading…
Reference in a new issue