sockethub 5.0.0-alpha.9 → 5.0.0-beta.1
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/sockethub +10 -4
- package/bin/sockethub-logged +109 -0
- package/package.json +16 -12
- package/sockethub.config.json.sentry +0 -7
package/bin/sockethub
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Startup failures before the server registers its own fatal handlers (a
|
|
3
|
+
// missing build, an unreadable config) would otherwise surface as an
|
|
4
|
+
// unhandled rejection with no clean message and no exit code.
|
|
5
|
+
import("@sockethub/server")
|
|
6
|
+
.then((sockethub) => sockethub.server())
|
|
7
|
+
.catch((err) => {
|
|
8
|
+
console.error(err);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Sockethub launcher with split logging:
|
|
4
|
+
* - Console: filtered via namespace patterns
|
|
5
|
+
* - File: full debug output to sockethub.log
|
|
6
|
+
*/
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import { createWriteStream } from "node:fs";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
|
|
11
|
+
// Console namespace filter. Include patterns show a namespace; a leading "-"
|
|
12
|
+
// excludes it; "*" matches any run of characters. (Self-contained matcher so we
|
|
13
|
+
// don't depend on the legacy `debug` package — Sockethub logs via winston.)
|
|
14
|
+
const CONSOLE_FILTER = [
|
|
15
|
+
"sockethub:init",
|
|
16
|
+
"sockethub:server:bootstrap:*",
|
|
17
|
+
"sockethub:server:core",
|
|
18
|
+
"-sockethub:server:core:*", // exclude per-session logs
|
|
19
|
+
"sockethub:server:listener",
|
|
20
|
+
"sockethub:server:janitor",
|
|
21
|
+
"sockethub:server:rate-limiter",
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
function patternToRegExp(pattern: string): RegExp {
|
|
25
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
26
|
+
return new RegExp(`^${escaped.replace(/\*/g, ".*?")}$`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const includes = CONSOLE_FILTER.filter((p) => !p.startsWith("-")).map(
|
|
30
|
+
patternToRegExp,
|
|
31
|
+
);
|
|
32
|
+
const excludes = CONSOLE_FILTER.filter((p) => p.startsWith("-")).map((p) =>
|
|
33
|
+
patternToRegExp(p.slice(1)),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const shouldShow = (namespace: string): boolean => {
|
|
37
|
+
if (excludes.some((re) => re.test(namespace))) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return includes.some((re) => re.test(namespace));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Extract the sockethub namespace from a winston log line
|
|
44
|
+
// (e.g. "2026-… debug: sockethub:server:core message", with optional ANSI colors)
|
|
45
|
+
const namespaceRegex = /sockethub:[^\s\x1b]+/;
|
|
46
|
+
function getNamespace(line: string): string | null {
|
|
47
|
+
const match = line.match(namespaceRegex);
|
|
48
|
+
return match ? match[0] : null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const logFile = createWriteStream("sockethub.log", { flags: "a" });
|
|
52
|
+
const timestamp = () => new Date().toISOString();
|
|
53
|
+
|
|
54
|
+
logFile.write(`\n--- Sockethub started at ${timestamp()} ---\n`);
|
|
55
|
+
|
|
56
|
+
const child = spawn("bun", ["run", join(dirname(import.meta.path), "sockethub")], {
|
|
57
|
+
env: { ...process.env, LOG_LEVEL: "debug" },
|
|
58
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
function processLine(line: string, stream: "stdout" | "stderr") {
|
|
62
|
+
// Always write to file
|
|
63
|
+
logFile.write(`${line}\n`);
|
|
64
|
+
|
|
65
|
+
// Check if namespace passes the console filter
|
|
66
|
+
// Non-debug lines (console.log from init, errors) are always shown
|
|
67
|
+
const namespace = getNamespace(line);
|
|
68
|
+
const show = namespace
|
|
69
|
+
? shouldShow(namespace)
|
|
70
|
+
: true; // show non-debug lines (startup banner, errors, etc)
|
|
71
|
+
|
|
72
|
+
if (show) {
|
|
73
|
+
if (stream === "stderr") {
|
|
74
|
+
process.stderr.write(`${line}\n`);
|
|
75
|
+
} else {
|
|
76
|
+
process.stdout.write(`${line}\n`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let stdoutBuffer = "";
|
|
82
|
+
let stderrBuffer = "";
|
|
83
|
+
|
|
84
|
+
child.stdout?.on("data", (data) => {
|
|
85
|
+
stdoutBuffer += data.toString();
|
|
86
|
+
const lines = stdoutBuffer.split("\n");
|
|
87
|
+
stdoutBuffer = lines.pop() || "";
|
|
88
|
+
for (const line of lines) {
|
|
89
|
+
processLine(line, "stdout");
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
child.stderr?.on("data", (data) => {
|
|
94
|
+
stderrBuffer += data.toString();
|
|
95
|
+
const lines = stderrBuffer.split("\n");
|
|
96
|
+
stderrBuffer = lines.pop() || "";
|
|
97
|
+
for (const line of lines) {
|
|
98
|
+
processLine(line, "stderr");
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
child.on("close", (code) => {
|
|
103
|
+
logFile.write(`--- Sockethub exited with code ${code} at ${timestamp()} ---\n`);
|
|
104
|
+
logFile.close();
|
|
105
|
+
process.exit(code || 0);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
process.on("SIGINT", () => child.kill("SIGINT"));
|
|
109
|
+
process.on("SIGTERM", () => child.kill("SIGTERM"));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sockethub",
|
|
3
3
|
"description": "A polyglot messaging service",
|
|
4
|
-
"version": "5.0.0-
|
|
4
|
+
"version": "5.0.0-beta.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Nick Jennings <nick@silverbucket.net>",
|
|
7
7
|
"license": "LGPL-3.0+",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bin": "bin/sockethub",
|
|
10
10
|
"preferGlobal": true,
|
|
11
11
|
"engines": {
|
|
12
|
-
"
|
|
12
|
+
"node": ">=20"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"sockethub",
|
|
@@ -33,21 +33,25 @@
|
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
|
35
35
|
"url": "git+https://github.com/sockethub/sockethub.git",
|
|
36
|
-
"directory": "
|
|
36
|
+
"directory": "packages/sockethub"
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://sockethub.org",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@sockethub/platform-
|
|
41
|
-
"@sockethub/platform-
|
|
42
|
-
"@sockethub/platform-
|
|
43
|
-
"@sockethub/platform-
|
|
44
|
-
"@sockethub/
|
|
40
|
+
"@sockethub/platform-caldav": "^1.0.0-beta.1",
|
|
41
|
+
"@sockethub/platform-carddav": "^1.0.0-beta.1",
|
|
42
|
+
"@sockethub/platform-dummy": "^3.0.0-beta.1",
|
|
43
|
+
"@sockethub/platform-feeds": "^4.0.0-beta.1",
|
|
44
|
+
"@sockethub/platform-irc": "^4.0.0-beta.1",
|
|
45
|
+
"@sockethub/platform-xmpp": "^5.0.0-beta.1",
|
|
46
|
+
"@sockethub/server": "^5.0.0-beta.1"
|
|
45
47
|
},
|
|
46
48
|
"scripts": {
|
|
47
49
|
"build": "bun build.js",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
50
|
+
"clean:deps": "rm -rf node_modules",
|
|
51
|
+
"dev": "SOCKETHUB_HTTP_ACTIONS_ENABLED=true bun run --hot ./bin/sockethub --examples",
|
|
52
|
+
"info": "node ./bin/sockethub --info",
|
|
53
|
+
"start": "node ./bin/sockethub",
|
|
54
|
+
"start:logged": "bun ./bin/sockethub-logged"
|
|
51
55
|
},
|
|
52
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "928f0c480e4828f492fb29a97712474a8f1bcaef"
|
|
53
57
|
}
|