Add service resize command to all 38 language implementations
Adds --resize ID --vcpu N flag to resize running services live.
PATCH /services/{id} with {"vcpu": 1-8} applies CPU/memory limits
without restart. Memory formula: 2GB per vCPU.
This commit is contained in:
parent
87397949d1
commit
c219d6e550
38 changed files with 1214 additions and 45 deletions
16
un.pl
16
un.pl
|
|
@ -524,6 +524,18 @@ sub cmd_service {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($options->{resize}) {
|
||||
unless ($options->{vcpu}) {
|
||||
print STDERR "${RED}Error: --vcpu is required with --resize${RESET}\n";
|
||||
exit 1;
|
||||
}
|
||||
my $payload = { vcpu => $options->{vcpu} };
|
||||
api_request("/services/$options->{resize}", 'PATCH', $payload, $public_key, $secret_key);
|
||||
my $ram = $options->{vcpu} * 2;
|
||||
print "${GREEN}Service resized to $options->{vcpu} vCPU, $ram GB RAM${RESET}\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if ($options->{execute}) {
|
||||
my $payload = { command => $options->{command} };
|
||||
my $result = api_request("/services/$options->{execute}/execute", 'POST', $payload, $public_key, $secret_key);
|
||||
|
|
@ -734,6 +746,7 @@ sub main {
|
|||
sleep => undef,
|
||||
wake => undef,
|
||||
destroy => undef,
|
||||
resize => undef,
|
||||
execute => undef,
|
||||
command => undef,
|
||||
dump_bootstrap => undef,
|
||||
|
|
@ -811,6 +824,8 @@ sub main {
|
|||
$options{wake} = $ARGV[++$i];
|
||||
} elsif ($arg eq '--destroy') {
|
||||
$options{destroy} = $ARGV[++$i];
|
||||
} elsif ($arg eq '--resize') {
|
||||
$options{resize} = $ARGV[++$i];
|
||||
} elsif ($arg eq '--execute') {
|
||||
$options{execute} = $ARGV[++$i];
|
||||
} elsif ($arg eq '--command') {
|
||||
|
|
@ -885,6 +900,7 @@ Service options:
|
|||
--freeze ID Freeze service
|
||||
--unfreeze ID Unfreeze service
|
||||
--destroy ID Destroy service
|
||||
--resize ID Resize service (requires -v)
|
||||
--execute ID Execute command in service
|
||||
--command CMD Command to execute (with --execute)
|
||||
--dump-bootstrap ID Dump bootstrap script
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue