Skip to content

Commit 916b36f

Browse files
committed
cleaner location for mounted in cocalc code
1 parent fcdf5a5 commit 916b36f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/packages/project-runner/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cocalc/project-runner",
3-
"version": "0.1.0",
3+
"version": "0.1.2",
44
"description": "CoCalc Project Runner",
55
"exports": {
66
"./run": "./dist/run/index.js"

src/packages/project-runner/run/mounts.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ export async function init() {
3434
logger.debug(MOUNTS);
3535
}
3636

37+
const COCALC_BIN = "/opt/cocalc/bin";
38+
export const COCALC_SRC = "/opt/cocalc/src";
3739
export function getCoCalcMounts() {
38-
nodePath = join("/cocalc/bin", basename(process.execPath));
40+
// NODEJS_SEA_PATH is where we mount the directory containing the nodejs SEA binary,
41+
// which we *also* use for running the project itself.
42+
nodePath = join(COCALC_BIN, basename(process.execPath));
3943
// IMPORTANT: take care not to put the binary next to sensitive info due
4044
// to mapping in process.execPath!
4145
return {
42-
[dirname(root)]: "/cocalc",
43-
[dirname(process.execPath)]: "/cocalc/bin",
46+
// /cocalc is where the project Javascript code is located; this is hardcoded
47+
// also in
48+
[join(dirname(root), "src")]: COCALC_SRC,
49+
[dirname(process.execPath)]: COCALC_BIN,
4450
};
4551
}
4652

src/packages/project-runner/run/podman.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import { mkdir } from "fs/promises";
1111
import { spawn } from "node:child_process";
1212
import { type Configuration } from "./types";
1313
export { type Configuration };
14-
import { getCoCalcMounts } from "./mounts";
14+
import { getCoCalcMounts, COCALC_SRC } from "./mounts";
1515
import { mountHome, setQuota } from "./filesystem";
1616
import { executeCode } from "@cocalc/backend/execute-code";
17+
import { join } from "path";
1718

1819
const logger = getLogger("project-runner:podman");
1920
const children: { [project_id: string]: any } = {};
@@ -60,7 +61,7 @@ export async function start({
6061

6162
const args: string[] = ["run", "--rm", "--network=host", "--user=0:0"];
6263
const cmd = "podman";
63-
const script = "/cocalc/src/packages/project/bin/cocalc-project.js";
64+
const script = join(COCALC_SRC, "/packages/project/bin/cocalc-project.js");
6465

6566
args.push("--hostname", `project-${project_id}`);
6667
args.push("--name", `project-${project_id}`);

0 commit comments

Comments
 (0)