Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silent-ends-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/cli": patch
---

follow log on run logs option
33 changes: 21 additions & 12 deletions apps/cli/src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import {
} from "@commander-js/extra-typings";
import { ExitPromptError } from "@inquirer/core";
import chalk from "chalk";
import { ExecaError } from "execa";
import getPort, { portNumbers } from "get-port";
import ora from "ora";
import { type Address, type Hex, numberToHex } from "viem";
import { getMachineHash, getProjectName } from "../base.js";
import { DEFAULT_SDK_VERSION, PREFERRED_PORT } from "../config.js";
import {
AVAILABLE_SERVICES,
type RollupsDeployment,
deployApplication,
removeApplication,
type RollupsDeployment,
startEnvironment,
stopEnvironment,
waitHealthyEnvironment,
Expand Down Expand Up @@ -64,9 +65,22 @@ const shell = async (options: {
);
switch (option) {
case "l": {
await log?.parseAsync(["--project-name", projectName], {
from: "user",
});
try {
await log?.parseAsync(
["--project-name", projectName, "--follow"],
{
from: "user",
},
);
} catch (error: unknown) {
if (error instanceof ExecaError) {
// just continue gracefully
if (error.exitCode === 130) {
break;
}
throw error;
}
}
break;
}
case "b": {
Expand Down Expand Up @@ -99,7 +113,6 @@ const shell = async (options: {
// gracefully exit
return;
}
console.error(error);
throw error;
}
}
Expand Down Expand Up @@ -285,13 +298,9 @@ export const createRunCommand = () => {
process.exit(0);
};

process.on("SIGINT", shutdown);
process.on("SIGTERM", shutdown);
process.on("uncaughtException", async (err) => {
console.error(err);
await shutdown();
process.exit(1);
});
// inhibit SIGINT and SIGTERM, will be handled gracefully by the shell
process.on("SIGINT", () => {});
process.on("SIGTERM", () => {});

const log = program.parent?.commands.find(
(c) => c.name() === "logs",
Expand Down
Loading