diff --git a/.changeset/tidy-dolphins-serve.md b/.changeset/tidy-dolphins-serve.md new file mode 100644 index 00000000..c0fe308a --- /dev/null +++ b/.changeset/tidy-dolphins-serve.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": patch +--- + +add --cpus and --memory to run command diff --git a/apps/cli/src/commands/run.ts b/apps/cli/src/commands/run.ts index db7c6105..4dd12bb6 100644 --- a/apps/cli/src/commands/run.ts +++ b/apps/cli/src/commands/run.ts @@ -54,6 +54,16 @@ export default class Run extends BaseCommand { description: "port to listen for incoming connections", default: 8080, }), + cpus: Flags.integer({ + description: + "Define the number of CPUs to use (eg.: 1) for the rollups-node", + summary: "number of cpu limits for the rollups-node", + }), + memory: Flags.integer({ + description: + "Define the amount of memory to use for the rollups-node in MB (eg.: 1024)", + summary: "memory limit for the rollups-node in MB", + }), "dry-run": Flags.boolean({ description: "show the docker compose configuration", default: false, @@ -104,10 +114,18 @@ export default class Run extends BaseCommand { CARTESI_SNAPSHOT_DIR: "/usr/share/rollups-node/snapshot", CARTESI_BIN_PATH: binPath, CARTESI_LISTEN_PORT: listenPort.toString(), + CARTESI_VALIDATOR_CPUS: flags.cpus?.toString(), + CARTESI_VALIDATOR_MEMORY: flags.memory?.toString(), }; // validator const composeFiles = ["docker-compose-validator.yaml"]; + if (flags.cpus) { + composeFiles.push("docker-compose-validator-cpus.yaml"); + } + if (flags.memory) { + composeFiles.push("docker-compose-validator-memory.yaml"); + } // prompt composeFiles.push("docker-compose-prompt.yaml"); diff --git a/apps/cli/src/node/docker-compose-validator-cpus.yaml b/apps/cli/src/node/docker-compose-validator-cpus.yaml new file mode 100644 index 00000000..eec5a1f5 --- /dev/null +++ b/apps/cli/src/node/docker-compose-validator-cpus.yaml @@ -0,0 +1,6 @@ +services: + validator: + deploy: + resources: + limits: + cpus: "${CARTESI_VALIDATOR_CPUS}" diff --git a/apps/cli/src/node/docker-compose-validator-memory.yaml b/apps/cli/src/node/docker-compose-validator-memory.yaml new file mode 100644 index 00000000..7334ef48 --- /dev/null +++ b/apps/cli/src/node/docker-compose-validator-memory.yaml @@ -0,0 +1,6 @@ +services: + validator: + deploy: + resources: + limits: + memory: "${CARTESI_VALIDATOR_MEMORY}M"