Skip to content

Commit 56a71df

Browse files
committed
get websocketfs to mount even "on my laptop", i.e., for some reason allowOther isn't supported, and it's better to work without root being allowed (which I think we don't need), then to mysteriously fail
1 parent 9235df5 commit 56a71df

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

src/compute/compute/dev/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ The scripts here are helpful for developing the compute\-server manager, which i
33
1. Create the directory /tmp/user and make sure you can read it. Maybe even mount it from the target project.
44

55
2. The conf/ directory here has the same files as on /cocalc/conf in an actual compute\-server, except:
6-
- replace api_server by something like `http://localhost:5000/6659c2e3-ff5e-4bb4-9a43-8830aa951282/port/5000`, where the port is what you're using for your dev server and the project id is of your dev server. The point is that we're going to connect directly without going through some external server.
6+
- replace api_server by something like `http://127.0.0.1:5000/6659c2e3-ff5e-4bb4-9a43-8830aa951282/port/5000`, where the port is what you're using for your dev server and the project id is of your dev server. The point is that we're going to connect directly without going through some external server.
77
- api_key: the one from an actual server will get deleted when you turn that server off, so make a different project level api key.
88

9-
Type `tar xvf conf.tar` to get a template for the conf directory. You will need to change the contents
10-
of all the files you get, as mentioned above!
9+
Type `tar xvf conf.tar` to get a template for the conf directory.
10+
You will need to change the contents of all the files you get, as
11+
mentioned above! Also, regarding the api_server, be especially careful
12+
about ipv4 versus ipv6, e.g., use 127.0.0.1 instead of localhost to
13+
nail down the protocol.
1114

1215
This is potentially confusing, and when developing this it was 10x worse... Maybe you'll be confused for 2 hours instead of 2 days.
1316

src/compute/compute/dev/start-filesystem.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ async function main() {
5858
});
5959
unmount = exports.fs.unmount;
6060
} catch (err) {
61-
console.log("something went wrong ", err);
61+
console.trace("something went wrong ", err);
6262
exitHandler();
63+
return;
6364
}
6465

6566
const info = () => {

src/compute/compute/lib/filesystem.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { mount } from "websocketfs";
1111
import getLogger from "@cocalc/backend/logger";
1212
import { project } from "@cocalc/api-client";
1313
import { serialize } from "cookie";
14-
import { join } from "path";
1514
import { API_COOKIE_NAME } from "@cocalc/backend/auth/cookie-names";
1615
import syncFS from "@cocalc/sync-fs";
1716
import {
@@ -100,7 +99,7 @@ export async function mountProject({
10099
// Ping to start project so it's possible to mount.
101100
await pingProjectUntilSuccess(project_id);
102101

103-
const remote = join(getProjectWebsocketUrl(project_id), "websocketfs");
102+
const remote = getProjectWebsocketUrl(project_id) + "/websocketfs";
104103
log("connecting to ", remote);
105104
const headers = { Cookie: serialize(API_COOKIE_NAME, apiKey) };
106105
// SECURITY: DO NOT log headers and connectOptions, obviously!
@@ -139,7 +138,7 @@ export async function mountProject({
139138
progress: 30,
140139
});
141140

142-
({ unmount } = await mount({
141+
const websocketfsMountOptions = {
143142
remote,
144143
path: homeMountPoint,
145144
...options,
@@ -163,7 +162,21 @@ export async function mountProject({
163162
readTrackingExclude: exclude,
164163
// metadata file
165164
metadataFile,
166-
}));
165+
};
166+
167+
log("websocketfs -- mount options", websocketfsMountOptions);
168+
169+
try {
170+
({ unmount } = await mount(websocketfsMountOptions));
171+
} catch (err) {
172+
log("failed trying to mount -- ", err);
173+
log(
174+
"try again without allowOther, since some versions of FUSE do not support this option",
175+
);
176+
websocketfsMountOptions.mountOptions.allowOther = false;
177+
({ unmount } = await mount(websocketfsMountOptions));
178+
}
179+
167180
pingInterval = setInterval(async () => {
168181
try {
169182
await project.ping({ project_id });

0 commit comments

Comments
 (0)