Skip to content

Commit

Permalink
internal: add debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
omermecitoglu committed Jan 8, 2025
1 parent 877bebf commit 27125c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function checkFile(filePath: string) {
}
}

function spawnChildProcess(detached: boolean) {
function spawnChildProcess(detached: boolean, debug: boolean) {
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const appPath = resolve(__dirname, "../ui/server.js");
Expand All @@ -29,6 +29,7 @@ function spawnChildProcess(detached: boolean) {
WEBHOOK_SECRET: "buttler",
CURRENT_WORKING_DIRECTORY: process.cwd(),
DRIZZLE_DIR: resolve(__dirname, "../drizzle"),
...(debug ? { DEBUG_MODE: "yes" } : {}),
},
});
if (detached) child.unref();
Expand All @@ -44,7 +45,7 @@ async function start(development: boolean) {
if (exists) {
return console.warn("the application is already running");
}
const pid = spawnChildProcess(!development);
const pid = spawnChildProcess(!development, development);
await fs.writeFile(pidFilePath, `${pid}`, "utf8");
console.log("the application has started");
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { ServiceDTO } from "~/models/service";
import createBuildImage from "~/operations/createBuildImage";
import updateBuildImage from "~/operations/updateBuildImage";
import updateService from "~/operations/updateService";
import env from "./env";
import { getProviderVariables } from "./provider";

export async function startBuilding(service: ServiceDTO) {
Expand All @@ -17,7 +18,7 @@ export async function startBuilding(service: ServiceDTO) {
try {
const repoPath = await cloneRepo(service.repo, service.id);
const networkId = service.providers.at(0)?.networkIds.at(0);
const success = await buildImage(image.id, repoPath, service.environmentVariables, networkId, false);
const success = await buildImage(image.id, repoPath, service.environmentVariables, networkId, env.DEBUG_MODE === "yes");
await deleteRepo(service.id);
if (success) {
await updateBuildImage(db, image.id, { status: "ready" });
Expand Down
1 change: 1 addition & 0 deletions src/core/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import z from "zod";

const EnvSchema = z.object({
CURRENT_WORKING_DIRECTORY: z.string().default(process.cwd()),
DEBUG_MODE: z.enum(["yes"]).optional(),
});

const env = EnvSchema.parse(process.env);
Expand Down

0 comments on commit 27125c4

Please sign in to comment.