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
22
un.m
22
un.m
|
|
@ -663,6 +663,7 @@ void cmdService(NSArray* args) {
|
|||
NSString* sleepId = nil;
|
||||
NSString* wakeId = nil;
|
||||
NSString* destroyId = nil;
|
||||
NSString* resizeId = nil;
|
||||
NSString* dumpBootstrapId = nil;
|
||||
NSString* dumpFile = nil;
|
||||
NSString* name = nil;
|
||||
|
|
@ -736,6 +737,10 @@ void cmdService(NSArray* args) {
|
|||
wakeId = args[++i];
|
||||
} else if ([arg isEqualToString:@"--destroy"] && i + 1 < [args count]) {
|
||||
destroyId = args[++i];
|
||||
} else if ([arg isEqualToString:@"--resize"] && i + 1 < [args count]) {
|
||||
resizeId = args[++i];
|
||||
} else if ([arg isEqualToString:@"--vcpu"] && i + 1 < [args count]) {
|
||||
vcpu = [args[++i] intValue];
|
||||
} else if ([arg isEqualToString:@"--dump-bootstrap"] && i + 1 < [args count]) {
|
||||
dumpBootstrapId = args[++i];
|
||||
} else if ([arg isEqualToString:@"--dump-file"] && i + 1 < [args count]) {
|
||||
|
|
@ -833,6 +838,23 @@ void cmdService(NSArray* args) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (resizeId) {
|
||||
if (vcpu <= 0) {
|
||||
fprintf(stderr, "%sError: --resize requires --vcpu or -v%s\n", [RED UTF8String], [RESET UTF8String]);
|
||||
exit(1);
|
||||
}
|
||||
if (vcpu < 1 || vcpu > 8) {
|
||||
fprintf(stderr, "%sError: vCPU must be between 1 and 8%s\n", [RED UTF8String], [RESET UTF8String]);
|
||||
exit(1);
|
||||
}
|
||||
NSString* endpoint = [NSString stringWithFormat:@"/services/%@", resizeId];
|
||||
NSDictionary* payload = @{@"vcpu": @(vcpu)};
|
||||
apiRequest(endpoint, @"PATCH", payload, publicKey, secretKey);
|
||||
int ram = vcpu * 2;
|
||||
printf("%sService resized to %d vCPU, %d GB RAM%s\n", [GREEN UTF8String], vcpu, ram, [RESET UTF8String]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dumpBootstrapId) {
|
||||
fprintf(stderr, "Fetching bootstrap script from %s...\n", [dumpBootstrapId UTF8String]);
|
||||
NSDictionary* payload = @{@"command": @"cat /tmp/bootstrap.sh"};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue