clay-server 2.11.0-beta.23 → 2.11.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +24 -1
- package/lib/daemon.js +7 -1
- package/lib/server.js +3 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -25,7 +25,10 @@ var net = require("net");
|
|
|
25
25
|
var _isDev = (process.argv[1] && path.basename(process.argv[1]) === "clay-dev") || process.argv.includes("--dev");
|
|
26
26
|
if (_isDev) {
|
|
27
27
|
process.env.CLAY_DEV = "1";
|
|
28
|
-
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Preserve console output in dev/debug mode so logs remain readable
|
|
31
|
+
if (_isDev || process.argv.includes("--debug")) {
|
|
29
32
|
console.clear = function() {};
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -450,6 +453,16 @@ async function restartDaemonFromConfig() {
|
|
|
450
453
|
saveConfig(newConfig);
|
|
451
454
|
|
|
452
455
|
var daemonScript = path.join(__dirname, "..", "lib", "daemon.js");
|
|
456
|
+
|
|
457
|
+
// Debug mode: run in foreground with logs to stdout
|
|
458
|
+
if (debugMode) {
|
|
459
|
+
process.env.CLAY_CONFIG = configPath();
|
|
460
|
+
newConfig.pid = process.pid;
|
|
461
|
+
saveConfig(newConfig);
|
|
462
|
+
require(daemonScript);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
453
466
|
var logFile = logPath();
|
|
454
467
|
var logFd = fs.openSync(logFile, "a");
|
|
455
468
|
|
|
@@ -1471,6 +1484,16 @@ async function forkDaemon(mode, keepAwake, extraProjects, addCwd, wantOsUsers) {
|
|
|
1471
1484
|
|
|
1472
1485
|
// Fork daemon
|
|
1473
1486
|
var daemonScript = path.join(__dirname, "..", "lib", "daemon.js");
|
|
1487
|
+
|
|
1488
|
+
// Debug mode: run in foreground with logs to stdout
|
|
1489
|
+
if (debugMode) {
|
|
1490
|
+
process.env.CLAY_CONFIG = configPath();
|
|
1491
|
+
config.pid = process.pid;
|
|
1492
|
+
saveConfig(config);
|
|
1493
|
+
require(daemonScript);
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1474
1497
|
var logFile = logPath();
|
|
1475
1498
|
var logFd = fs.openSync(logFile, "a");
|
|
1476
1499
|
|
package/lib/daemon.js
CHANGED
|
@@ -150,6 +150,7 @@ var relay = createServer({
|
|
|
150
150
|
return { ok: true, slug: slug };
|
|
151
151
|
},
|
|
152
152
|
onCreateProject: function (projectName, wsUser) {
|
|
153
|
+
console.log("[daemon] onCreateProject wsUser:", JSON.stringify(wsUser ? { id: wsUser.id, role: wsUser.role, username: wsUser.username, linuxUser: wsUser.linuxUser } : null));
|
|
153
154
|
var os = require("os");
|
|
154
155
|
var { execSync } = require("child_process");
|
|
155
156
|
var baseDir;
|
|
@@ -205,10 +206,13 @@ var relay = createServer({
|
|
|
205
206
|
config.projects.push(projectEntry);
|
|
206
207
|
saveConfig(config);
|
|
207
208
|
try { syncClayrc(config.projects); } catch (e) {}
|
|
208
|
-
console.log("[daemon] Created project:", slug, "→", targetDir);
|
|
209
|
+
console.log("[daemon] Created project:", slug, "→", targetDir, "entry:", JSON.stringify({ ownerId: projectEntry.ownerId, visibility: projectEntry.visibility }));
|
|
209
210
|
// OS users mode: grant ACL
|
|
210
211
|
if (config.osUsers && wsUser && wsUser.linuxUser) {
|
|
212
|
+
console.log("[daemon] Granting ACL:", targetDir, "→", wsUser.linuxUser);
|
|
211
213
|
grantProjectAccess(targetDir, wsUser.linuxUser);
|
|
214
|
+
} else if (config.osUsers) {
|
|
215
|
+
console.log("[daemon] Skipping ACL grant: osUsers=true but linuxUser=", wsUser && wsUser.linuxUser);
|
|
212
216
|
}
|
|
213
217
|
relay.broadcastAll({
|
|
214
218
|
type: "projects_updated",
|
|
@@ -401,6 +405,7 @@ var relay = createServer({
|
|
|
401
405
|
return { ok: true };
|
|
402
406
|
},
|
|
403
407
|
onProjectOwnerChanged: function (slug, ownerId) {
|
|
408
|
+
console.log("[daemon] onProjectOwnerChanged:", slug, "→", ownerId);
|
|
404
409
|
var oldOwnerId = null;
|
|
405
410
|
var projectIdx = -1;
|
|
406
411
|
for (var oi = 0; oi < config.projects.length; oi++) {
|
|
@@ -431,6 +436,7 @@ var relay = createServer({
|
|
|
431
436
|
// Grant new owner
|
|
432
437
|
if (ownerId) {
|
|
433
438
|
var newOwner = usersModule.findUserById(ownerId);
|
|
439
|
+
console.log("[daemon] Owner grant ACL:", ownerId, "linuxUser:", newOwner && newOwner.linuxUser, "path:", projectPath);
|
|
434
440
|
if (newOwner && newOwner.linuxUser) {
|
|
435
441
|
grantProjectAccess(projectPath, newOwner.linuxUser);
|
|
436
442
|
}
|
package/lib/server.js
CHANGED
|
@@ -1964,6 +1964,7 @@ function createServer(opts) {
|
|
|
1964
1964
|
|
|
1965
1965
|
var ctx = projects.get(wsSlug);
|
|
1966
1966
|
if (!ctx) {
|
|
1967
|
+
if (debug) console.log("[server] WS rejected: project not found for slug", wsSlug);
|
|
1967
1968
|
socket.destroy();
|
|
1968
1969
|
return;
|
|
1969
1970
|
}
|
|
@@ -1975,8 +1976,10 @@ function createServer(opts) {
|
|
|
1975
1976
|
// Check project access for multi-user mode
|
|
1976
1977
|
if (wsUser && onGetProjectAccess) {
|
|
1977
1978
|
var projectAccess = onGetProjectAccess(wsSlug);
|
|
1979
|
+
if (debug) console.log("[server] WS access check:", wsSlug, "user:", wsUser.id, "role:", wsUser.role, "visibility:", projectAccess && projectAccess.visibility, "ownerId:", projectAccess && projectAccess.ownerId, "allowed:", projectAccess && projectAccess.allowedUsers);
|
|
1978
1980
|
if (projectAccess && !projectAccess.error) {
|
|
1979
1981
|
if (!users.canAccessProject(wsUser.id, projectAccess)) {
|
|
1982
|
+
if (debug) console.log("[server] WS rejected: access denied for", wsUser.id, "on", wsSlug);
|
|
1980
1983
|
socket.write("HTTP/1.1 403 Forbidden\r\n\r\n");
|
|
1981
1984
|
socket.destroy();
|
|
1982
1985
|
return;
|