querysub 0.270.0 → 0.272.0
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/package.json
CHANGED
|
@@ -41,7 +41,7 @@ import { waitForFirstTimeSync } from "socket-function/time/trueTimeShim";
|
|
|
41
41
|
import { logMeasureTable, measureBlock, measureFnc, measureWrap, startMeasure } from "socket-function/src/profiling/measure";
|
|
42
42
|
import { delay } from "socket-function/src/batching";
|
|
43
43
|
import { MaybePromise } from "socket-function/src/types";
|
|
44
|
-
import { devDebugbreak, getDomain, isDynamicallyLoading, isPublic, noSyncing } from "../config";
|
|
44
|
+
import { devDebugbreak, getDomain, isBootstrapOnly, isDynamicallyLoading, isPublic, noSyncing } from "../config";
|
|
45
45
|
import { Schema2, Schema2T, t } from "../2-proxy/schema2";
|
|
46
46
|
import { CALL_PERMISSIONS_KEY } from "./permissionsShared";
|
|
47
47
|
import yargs, { check } from "yargs";
|
|
@@ -67,8 +67,6 @@ let yargObj = parseArgsFactory()
|
|
|
67
67
|
.option("verbosenetwork", { type: "boolean", desc: "Log all network activity" })
|
|
68
68
|
.option("verboseframework", { type: "boolean", desc: "Log internal SocketFunction framework" })
|
|
69
69
|
.option("nodelay", { type: "boolean", desc: "Don't delay committing functions, even ones that are marked to be delayed." })
|
|
70
|
-
// TODO: The bootstrapper is a single file. Maybe we shouldn't run the entire service just for that. Although... maybe it's fine, as services are light?
|
|
71
|
-
.option("bootstraponly", { type: "boolean", desc: "Don't register as an edge node, so we serve the bootstrap files, but we don't need up to date code because we are not used for endpoints or the UI." })
|
|
72
70
|
.argv
|
|
73
71
|
;
|
|
74
72
|
setImmediate(() => {
|
|
@@ -769,7 +767,7 @@ export class Querysub {
|
|
|
769
767
|
}
|
|
770
768
|
allowHostnames.push("127-0-0-1." + getDomain());
|
|
771
769
|
|
|
772
|
-
if (
|
|
770
|
+
if (isBootstrapOnly() && isPublic()) {
|
|
773
771
|
if (config.port !== 443) {
|
|
774
772
|
throw new Error(`--bootstraponly requires you to set port 443. There can only be one bootstrap node per server.`);
|
|
775
773
|
}
|
|
@@ -790,7 +788,7 @@ export class Querysub {
|
|
|
790
788
|
|
|
791
789
|
let { ip, ipDomain } = await publishMachineARecords();
|
|
792
790
|
|
|
793
|
-
if (!
|
|
791
|
+
if (!isBootstrapOnly()) {
|
|
794
792
|
await registerEdgeNode({
|
|
795
793
|
host: ipDomain + ":" + config.port,
|
|
796
794
|
entryPaths,
|
|
@@ -43,7 +43,7 @@ setFlag(require, "preact", "allowclient", true);
|
|
|
43
43
|
import yargs from "yargs";
|
|
44
44
|
import { mergeFilterables, parseFilterable, serializeFilterable } from "../misc/filterable";
|
|
45
45
|
import { isManagementUser, onAllPredictionsFinished } from "../-0-hooks/hooks";
|
|
46
|
-
import { isLocal } from "../config";
|
|
46
|
+
import { isBootstrapOnly, isLocal } from "../config";
|
|
47
47
|
|
|
48
48
|
let yargObj = isNodeTrue() && yargs(process.argv)
|
|
49
49
|
.option("fncfilter", { type: "string", default: "", desc: `Sets the filterable state for function calls, causing them to target specific FunctionRunners. If no FunctionRunner matches, all functions will fail to run. For example: "devtestserver" will match a FunctionRunner that uses the "devtestserver" filter. Merges with the existing filterable state if a client sets it explicitly.` })
|
|
@@ -262,6 +262,7 @@ export async function baseAddCall(call: CallSpec, nodeId: string, cancel: () =>
|
|
|
262
262
|
|
|
263
263
|
export class QuerysubControllerBase {
|
|
264
264
|
public async watch(config: WatchConfig) {
|
|
265
|
+
if (isBootstrapOnly()) throw new Error(`Cannot watch on bootstrap only server`);
|
|
265
266
|
for (let path of config.paths) {
|
|
266
267
|
Querysub.assertDomainAllowed(path);
|
|
267
268
|
}
|
|
@@ -485,6 +486,7 @@ export class QuerysubControllerBase {
|
|
|
485
486
|
};
|
|
486
487
|
}
|
|
487
488
|
public async unwatch(config: WatchConfig) {
|
|
489
|
+
if (isBootstrapOnly()) throw new Error(`Cannot unwatch on bootstrap only server`);
|
|
488
490
|
let pHash = permissionsHash(SocketFunction.getCaller());
|
|
489
491
|
let callerId = SocketFunction.getCaller().nodeId;
|
|
490
492
|
let permissionsObjIn = permissionsPerNode.get(pHash);
|
|
@@ -516,6 +518,7 @@ export class QuerysubControllerBase {
|
|
|
516
518
|
}
|
|
517
519
|
|
|
518
520
|
public async addCall(call: CallSpec) {
|
|
521
|
+
if (isBootstrapOnly()) throw new Error(`Cannot add calls to bootstrap only server`);
|
|
519
522
|
if (Querysub.DEBUG_CALLS) {
|
|
520
523
|
console.log(`[Querysub] addCall @${debugTime(call.runAtTime)}: ${call.DomainName}.${call.ModuleId}.${call.FunctionId}`);
|
|
521
524
|
}
|
|
@@ -600,6 +603,7 @@ export class QuerysubControllerBase {
|
|
|
600
603
|
FunctionId: string;
|
|
601
604
|
};
|
|
602
605
|
}): Promise<string> {
|
|
606
|
+
if (isBootstrapOnly()) throw new Error(`Cannot get module path on bootstrap only server`);
|
|
603
607
|
let spec = config.functionSpec;
|
|
604
608
|
Querysub.assertDomainAllowed(getPathStr1(spec.DomainName));
|
|
605
609
|
|
|
@@ -620,6 +624,7 @@ export class QuerysubControllerBase {
|
|
|
620
624
|
ModuleId: string;
|
|
621
625
|
FunctionId: string;
|
|
622
626
|
}) {
|
|
627
|
+
if (isBootstrapOnly()) throw new Error(`Cannot get dev function spec from call on bootstrap only server`);
|
|
623
628
|
let functionSpec = getDevFunctionSpecFromCall(call);
|
|
624
629
|
if (!functionSpec) return undefined;
|
|
625
630
|
let modulePath = (await getModuleFromConfig(functionSpec)).filename;
|
package/src/config.ts
CHANGED
|
@@ -18,6 +18,8 @@ let yargObj = parseArgsFactory()
|
|
|
18
18
|
.option("local", { type: "boolean", desc: `If true, uses the local directory instead of the remote git repo. Also hotreloads from disk. Determines the repo to replace through the package.json "repository" property.` })
|
|
19
19
|
.option("nosyncing", { type: "boolean", desc: `Disabled any syncing code, just using HTTP. Still manages routing via backblaze though.` })
|
|
20
20
|
.option("recovery", { type: "boolean", desc: `Allows any localhost connections to act like a superuser (and a trusted node), to help recover the database (as you need permission to access the snapshot page).` })
|
|
21
|
+
// TODO: The bootstrapper is a single file. Maybe we shouldn't run the entire service just for that. Although... maybe it's fine, as services are light?
|
|
22
|
+
.option("bootstraponly", { type: "boolean", desc: "Don't register as an edge node, so we serve the bootstrap files, but we don't need up to date code because we are not used for endpoints or the UI." })
|
|
21
23
|
.argv
|
|
22
24
|
;
|
|
23
25
|
|
|
@@ -41,6 +43,10 @@ export function isNoNetwork() {
|
|
|
41
43
|
return yargObj.nonetwork;
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
export function isBootstrapOnly() {
|
|
47
|
+
return yargObj.bootstraponly;
|
|
48
|
+
}
|
|
49
|
+
|
|
44
50
|
export function getDomain() {
|
|
45
51
|
if (!isNode()) {
|
|
46
52
|
return location.hostname.split(".").slice(-2).join(".");
|
|
@@ -22,13 +22,15 @@ export class RenderGitRefInfo extends qreact.Component<{
|
|
|
22
22
|
}> {
|
|
23
23
|
render() {
|
|
24
24
|
let controller = MachineServiceController(SocketFunction.browserNodeId());
|
|
25
|
+
let gitRef = this.props.gitRef;
|
|
25
26
|
let gitRefInfo = controller.getGitRefInfo({
|
|
26
|
-
ref:
|
|
27
|
+
ref: gitRef,
|
|
27
28
|
useQuerysub: this.props.isQuerysub,
|
|
28
29
|
});
|
|
29
30
|
if (!gitRefInfo) return undefined;
|
|
31
|
+
let { description, time } = gitRefInfo;
|
|
30
32
|
return <div className={css.fontWeight("normal")}>
|
|
31
|
-
{formatDateJSX(
|
|
33
|
+
{formatDateJSX(time)} AGO <span className={css.hsl(0, 0, 80).pad2(5, 2).italic}>{description}</span> ({gitRef.slice(0, 6)})
|
|
32
34
|
</div>;
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -259,6 +259,18 @@ export class MachineServiceControllerBase {
|
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
public async commitPushService(commitMessage: string) {
|
|
262
|
+
if (commitMessage.toLowerCase().includes("querysub")) {
|
|
263
|
+
let querysubFolder = path.resolve("../querysub");
|
|
264
|
+
if (fs.existsSync(querysubFolder)) {
|
|
265
|
+
let querysubLastCommit = await getGitRefInfo({
|
|
266
|
+
gitDir: querysubFolder,
|
|
267
|
+
ref: "origin/main",
|
|
268
|
+
});
|
|
269
|
+
if (querysubLastCommit) {
|
|
270
|
+
commitMessage += `\n\n(querysub commit): ${querysubLastCommit.description}`;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
262
274
|
await commitAndPush({
|
|
263
275
|
gitDir: ".",
|
|
264
276
|
message: commitMessage,
|