runcloud 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +4 -0
- package/dist/commands/sandbox.js +10 -13
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -52,6 +52,10 @@ export class ApiClient {
|
|
|
52
52
|
get(path) {
|
|
53
53
|
return this.request('GET', path);
|
|
54
54
|
}
|
|
55
|
+
async getText(path) {
|
|
56
|
+
const response = await this.request('GET', path);
|
|
57
|
+
return response.text();
|
|
58
|
+
}
|
|
55
59
|
post(path, body) {
|
|
56
60
|
return this.request('POST', path, body);
|
|
57
61
|
}
|
package/dist/commands/sandbox.js
CHANGED
|
@@ -10,6 +10,7 @@ import { printJson, StatusLine, style } from '../terminal.js';
|
|
|
10
10
|
import { noteDeprecated, registerAccessCommands } from './boxAccess.js';
|
|
11
11
|
import { renderSandbox, renderSandboxList, } from './sandboxOutput.js';
|
|
12
12
|
const MAX_SANDBOX_DISK_GIB = 2048;
|
|
13
|
+
const DEFAULT_SANDBOX_TIMEOUT_SECONDS = 300;
|
|
13
14
|
const DEFAULT_BOX_CPU_CORES = 2;
|
|
14
15
|
const DEFAULT_BOX_MEMORY_MIB = 24 * 1024;
|
|
15
16
|
const SANDBOX_POLL_INTERVAL_MS = 1_000;
|
|
@@ -283,7 +284,7 @@ export function registerSandbox(program) {
|
|
|
283
284
|
.option('--memory <mb>', 'memory allocation in MiB', parseMemoryMb)
|
|
284
285
|
.option('--disk <gb>', 'root disk capacity in GiB', parseDiskGb)
|
|
285
286
|
.option('--idle-pause <seconds>', 'pause after inactivity; 0 keeps it running', parseIdlePauseSeconds)
|
|
286
|
-
.option('--timeout <seconds>', 'maximum sandbox lifetime; 0
|
|
287
|
+
.option('--timeout <seconds>', 'maximum sandbox lifetime; defaults to 300, or 0 for persistent sandboxes', parseTimeoutSeconds)
|
|
287
288
|
.option('--persistent', 'never pause when idle (same as --idle-pause 0)', false)
|
|
288
289
|
.option('--expose <port>', 'publish a guest port at <name>-box.run.cloud; implies --persistent', parsePort)
|
|
289
290
|
.option('--secret-group <group>', 'attach a secret group; repeatable and ORDER MATTERS (a later group wins on a name collision)', collectRepeatable, [])
|
|
@@ -315,7 +316,8 @@ export function registerSandbox(program) {
|
|
|
315
316
|
body.memory = memory;
|
|
316
317
|
if (opts.disk !== undefined)
|
|
317
318
|
body.disk = opts.disk;
|
|
318
|
-
|
|
319
|
+
const persistent = exposed || opts.persistent || opts.idlePause === 0;
|
|
320
|
+
body.timeoutSeconds = opts.timeout ?? (persistent ? 0 : DEFAULT_SANDBOX_TIMEOUT_SECONDS);
|
|
319
321
|
if (exposed || opts.persistent)
|
|
320
322
|
body.idlePauseSeconds = 0;
|
|
321
323
|
else if (opts.idlePause !== undefined)
|
|
@@ -527,23 +529,18 @@ export function registerSandbox(program) {
|
|
|
527
529
|
}
|
|
528
530
|
withOutput(sandbox
|
|
529
531
|
.command('logs')
|
|
530
|
-
.description('Show
|
|
532
|
+
.description('Show saved console logs (available after a sandbox is deleted)')
|
|
531
533
|
.argument('<id>', 'sandbox id')
|
|
532
534
|
.option('--lines <n>', 'number of lines to tail', '200')).action((id, opts) => run(async () => {
|
|
533
535
|
const n = Number(opts.lines) || 200;
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
'-c',
|
|
538
|
-
`j="$(journalctl -n ${n} --no-pager 2>/dev/null)"; if [ -n "$j" ]; then printf "%s\\n" "$j"; else tail -n ${n} /root/.natively/expo_server.log 2>&1 || echo '(no logs available)'; fi`,
|
|
539
|
-
],
|
|
540
|
-
});
|
|
536
|
+
const saved = await runCloudApi().getText(`/run-cloud/sandboxes/${encodeURIComponent(id)}/logs`);
|
|
537
|
+
const lines = saved.split('\n');
|
|
538
|
+
const logs = lines.slice(Math.max(0, lines.length - n - (saved.endsWith('\n') ? 1 : 0))).join('\n');
|
|
541
539
|
if (opts.json) {
|
|
542
|
-
|
|
540
|
+
printJson({ sandboxId: id, logs });
|
|
543
541
|
return;
|
|
544
542
|
}
|
|
545
|
-
process.stdout.write(
|
|
546
|
-
process.stderr.write(r.stderr ?? '');
|
|
543
|
+
process.stdout.write(logs);
|
|
547
544
|
}));
|
|
548
545
|
withOutput(sandbox
|
|
549
546
|
.command('desktop')
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.1.
|
|
1
|
+
export const CLI_VERSION = '0.1.21';
|