From b19972afc64bb9029b78c633e1841988af76adab Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Thu, 15 Oct 2020 11:54:46 -0700 Subject: With a MONITORED=true in .env, this should now work --- src/server/DashSession/Session/agents/monitor.ts | 6 +++--- src/server/DashSession/Session/utilities/session_config.ts | 2 +- src/server/index.ts | 11 ++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/server') diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts index ee8afee65..044a841ae 100644 --- a/src/server/DashSession/Session/agents/monitor.ts +++ b/src/server/DashSession/Session/agents/monitor.ts @@ -22,7 +22,7 @@ export class Monitor extends IPCMessageReceiver { private readonly config: Configuration; private activeWorker: Worker | undefined; private key: string | undefined; - // private repl: Repl; + private repl: Repl; public static Create() { if (isWorker) { @@ -46,7 +46,7 @@ export class Monitor extends IPCMessageReceiver { this.configureInternalHandlers(); this.config = this.loadAndValidateConfiguration(); this.initializeClusterFunctions(); - // this.repl = this.initializeRepl(); + this.repl = this.initializeRepl(); } protected configureInternalHandlers = () => { @@ -119,7 +119,7 @@ export class Monitor extends IPCMessageReceiver { * that can invoke application logic external to this module */ public addReplCommand = (basename: string, argPatterns: (RegExp | string)[], action: ReplAction) => { - // this.repl.registerCommand(basename, argPatterns, action); + this.repl.registerCommand(basename, argPatterns, action); } public exec = (command: string, options?: ExecOptions) => { diff --git a/src/server/DashSession/Session/utilities/session_config.ts b/src/server/DashSession/Session/utilities/session_config.ts index b0e65dde4..bde98e9d2 100644 --- a/src/server/DashSession/Session/utilities/session_config.ts +++ b/src/server/DashSession/Session/utilities/session_config.ts @@ -19,7 +19,7 @@ const identifierProperties: Schema = { const portProperties: Schema = { type: "number", - minimum: 1024, + minimum: 443, maximum: 65535 }; diff --git a/src/server/index.ts b/src/server/index.ts index c4e6be8a2..9687c3b23 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -23,6 +23,7 @@ import { Logger } from "./ProcessFactory"; import RouteManager, { Method, PublicHandler } from './RouteManager'; import RouteSubscriber from './RouteSubscriber'; import initializeServer, { resolvedPorts } from './server_Initialization'; +import { DashSessionAgent } from "./DashSession/DashSessionAgent"; export const AdminPriviliges: Map = new Map(); export const onWindows = process.platform === "win32"; @@ -186,9 +187,9 @@ export async function launchServer() { * log the output of the server process, so it's not ideal for development. * So, the 'else' clause is exactly what we've always run when executing npm start. */ -// if (process.env.RELEASE) { -// (sessionAgent = new DashSessionAgent()).launch(); -// } else { (Database.Instance as Database.Database).doConnect(); -launchServer(); -// } +if (process.env.MONITORED) { + (sessionAgent = new DashSessionAgent()).launch(); +} else { + launchServer(); +} -- cgit v1.2.3-70-g09d2 From 5816840af60f97a34318a52a5276482cab392496 Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 16 Oct 2020 15:48:54 -0400 Subject: updated user initialization code to not generate server traffic when creating a new account. set user accounts to update their cache 2.5s after login. --- src/client/DocServer.ts | 5 ++--- src/client/documents/Documents.ts | 4 +++- src/client/util/CurrentUserUtils.ts | 15 ++++++++++----- src/client/views/GlobalKeyHandler.ts | 2 +- src/client/views/Main.tsx | 3 ++- src/client/views/search/SearchBox.tsx | 2 +- src/server/websocket.ts | 11 +++++++---- 7 files changed, 26 insertions(+), 16 deletions(-) (limited to 'src/server') diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index 00f9877c3..1d7497cf8 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -28,13 +28,13 @@ import * as rp from 'request-promise'; export namespace DocServer { let _cache: { [id: string]: RefField | Promise> } = {}; - export function PRINT_CACHE() { + export function UPDATE_SERVER_CACHE(print: boolean = false) { const strings: string[] = []; Array.from(Object.keys(_cache)).forEach(key => { const doc = _cache[key]; if (doc instanceof Doc) strings.push(StrCast(doc.author) + " " + StrCast(doc.title) + " " + StrCast(Doc.GetT(doc, "title", "string", true))); }); - strings.sort().forEach((str, i) => console.log(i.toString() + " " + str)); + print && strings.sort().forEach((str, i) => console.log(i.toString() + " " + str)); rp.post(Utils.prepend("/setCacheDocumentIds"), { body: { cacheDocumentIds: Array.from(Object.keys(_cache)).join(";"), @@ -348,7 +348,6 @@ export namespace DocServer { } if (requestedIds.length) { - // 2) synchronously, we emit a single callback to the server requesting the serialized (i.e. represented by a string) // fields for the given ids. This returns a promise, which, when resolved, indicates that all the JSON serialized versions of // the fields have been returned from the server diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 45c465d84..d7c9af1a3 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -236,6 +236,8 @@ class EmptyBox { export namespace Docs { + export let newAccount: boolean = false; + export namespace Prototypes { type LayoutSource = { LayoutString: (key: string) => string }; @@ -392,7 +394,7 @@ export namespace Docs { // non-guid string ids for each document prototype const prototypeIds = Object.values(DocumentType).filter(type => type !== DocumentType.NONE).map(type => type + suffix); // fetch the actual prototype documents from the server - const actualProtos = await DocServer.GetRefFields(prototypeIds); + const actualProtos = Docs.newAccount ? {} : await DocServer.GetRefFields(prototypeIds); // update this object to include any default values: DocumentOptions for all prototypes prototypeIds.map(id => { diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index dcbeba8cd..f43b6df44 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -878,7 +878,7 @@ export class CurrentUserUtils { // Sharing sidebar is where shared documents are contained static async setupSharingSidebar(doc: Doc, sharingDocumentId: string, linkDatabaseId: string) { if (doc.myLinkDatabase === undefined) { - let linkDocs = await DocServer.GetRefField(linkDatabaseId); + let linkDocs = Docs.newAccount ? undefined : await DocServer.GetRefField(linkDatabaseId); if (!linkDocs) { linkDocs = new Doc(linkDatabaseId, true); (linkDocs as Doc).author = Doc.CurrentUserEmail; @@ -888,7 +888,7 @@ export class CurrentUserUtils { doc.myLinkDatabase = new PrefetchProxy(linkDocs); } if (doc.mySharedDocs === undefined) { - let sharedDocs = await DocServer.GetRefField(sharingDocumentId + "outer"); + let sharedDocs = Docs.newAccount ? undefined : await DocServer.GetRefField(sharingDocumentId + "outer"); if (!sharedDocs) { sharedDocs = Docs.Create.StackingDocument([], { title: "My SharedDocs", childDropAction: "alias", system: true, contentPointerEvents: "none", childLimitHeight: 0, _yMargin: 50, _gridGap: 15, @@ -1024,6 +1024,7 @@ export class CurrentUserUtils { // Doc.AddDocToList(Cast(doc["template-notes"], Doc, null), "data", deleg); // } // }); + setTimeout(() => DocServer.UPDATE_SERVER_CACHE(), 2500); return doc; } @@ -1047,8 +1048,12 @@ export class CurrentUserUtils { await rp.get(Utils.prepend("/getUserDocumentIds")).then(ids => { const { userDocumentId, sharingDocumentId, linkDatabaseId } = JSON.parse(ids); if (userDocumentId !== "guest") { - return DocServer.GetRefField(userDocumentId).then(async field => - this.updateUserDocument(Doc.SetUserDoc(field instanceof Doc ? field : new Doc(userDocumentId, true)), sharingDocumentId, linkDatabaseId)); + return DocServer.GetRefField(userDocumentId).then(async field => { + Docs.newAccount = !(field instanceof Doc); + await Docs.Prototypes.initialize(); + const userDoc = Docs.newAccount ? new Doc(userDocumentId, true) : field as Doc; + return this.updateUserDocument(Doc.SetUserDoc(userDoc), sharingDocumentId, linkDatabaseId); + }); } else { throw new Error("There should be a user id! Why does Dash think there isn't one?"); } @@ -1108,7 +1113,7 @@ export class CurrentUserUtils { const response = await fetch(upload, { method: "POST", body: formData }); const json = await response.json(); if (json !== "error") { - const doc = await DocServer.GetRefField(json); + const doc = Docs.newAccount ? undefined : await DocServer.GetRefField(json); if (doc instanceof Doc) { setTimeout(() => SearchUtil.Search(`{!join from=id to=proto_i}id:link*`, true, {}).then(docs => docs.docs.forEach(d => LinkManager.Instance.addLink(d))), 2000); // need to give solr some time to update so that this query will find any link docs we've added. diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts index 89292a445..fb360ee26 100644 --- a/src/client/views/GlobalKeyHandler.ts +++ b/src/client/views/GlobalKeyHandler.ts @@ -56,7 +56,7 @@ export class KeyManager { public handle = action(async (e: KeyboardEvent) => { if (e.key?.toLowerCase() === "shift" && e.ctrlKey && e.altKey) KeyManager.Instance.ShiftPressed = true; - if (!Doc.UserDoc().noviceMode && e.key.toLocaleLowerCase() === "shift") DocServer.PRINT_CACHE(); + if (!Doc.UserDoc().noviceMode && e.key.toLocaleLowerCase() === "shift") DocServer.UPDATE_SERVER_CACHE(true); const keyname = e.key && e.key.toLowerCase(); this.handleGreedy(keyname); diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index 3889e2d28..c256d2ebb 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -13,10 +13,11 @@ AssignAllExtensions(); (async () => { window.location.search.includes("safe") && CollectionView.SetSafeMode(true); const info = await CurrentUserUtils.loadCurrentUser(); - await Docs.Prototypes.initialize(); if (info.id !== "__guest__") { // a guest will not have an id registered await CurrentUserUtils.loadUserDocument(info.id); + } else { + await Docs.Prototypes.initialize(); } document.getElementById('root')!.addEventListener('wheel', event => { if (event.ctrlKey) { diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index bc00e93a5..3872cbb18 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -506,7 +506,7 @@ export class SearchBox extends ViewBoxBaseComponent -
DocServer.PRINT_CACHE()}> +
DocServer.UPDATE_SERVER_CACHE()}> {`UI project`}
diff --git a/src/server/websocket.ts b/src/server/websocket.ts index e5692a7dd..490760441 100644 --- a/src/server/websocket.ts +++ b/src/server/websocket.ts @@ -207,9 +207,12 @@ export namespace WebSocket { } } + function GetRefFieldLocal([id, callback]: [string, (result?: Transferable) => void]) { + return Database.Instance.getDocument(id, callback); + } function GetRefField([id, callback]: [string, (result?: Transferable) => void]) { process.stdout.write(`.`); - Database.Instance.getDocument(id, callback); + GetRefFieldLocal([id, callback]); } function GetRefFields([ids, callback]: [string[], (result?: Transferable[]) => void]) { @@ -311,9 +314,9 @@ export namespace WebSocket { function UpdateField(socket: Socket, diff: Diff) { - if (diff.diff.$addToSet) return GetRefField([diff.id, (result?: Transferable) => addToListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own - if (diff.diff.$remFromSet) return GetRefField([diff.id, (result?: Transferable) => remFromListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own - return GetRefField([diff.id, (result?: Transferable) => SetField(socket, diff, result)]); + if (diff.diff.$addToSet) return GetRefFieldLocal([diff.id, (result?: Transferable) => addToListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own + if (diff.diff.$remFromSet) return GetRefFieldLocal([diff.id, (result?: Transferable) => remFromListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own + return GetRefFieldLocal([diff.id, (result?: Transferable) => SetField(socket, diff, result)]); } function SetField(socket: Socket, diff: Diff, curListItems?: Transferable) { Database.Instance.update(diff.id, diff.diff, -- cgit v1.2.3-70-g09d2 From 37fc6beb4662be195b8aa551cc1042b04f2c24a8 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sat, 17 Oct 2020 22:01:53 -0400 Subject: fixed rubberbadning ink shapes not to get cutoff. fixed animating annotations. fixed ink masks. fixed warnings. --- src/client/views/InkingStroke.tsx | 4 +--- src/client/views/collections/CollectionMenu.tsx | 2 +- .../collectionFreeForm/CollectionFreeFormView.tsx | 6 ++++-- src/client/views/nodes/PresBox.tsx | 12 ++++++------ src/client/views/pdf/PDFViewer.tsx | 6 +++++- src/server/websocket.ts | 4 ++-- 6 files changed, 19 insertions(+), 15 deletions(-) (limited to 'src/server') diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx index 186406424..7e424d8f0 100644 --- a/src/client/views/InkingStroke.tsx +++ b/src/client/views/InkingStroke.tsx @@ -38,7 +38,7 @@ export class InkingStroke extends ViewBoxBaseComponent pair.layout).slice().sort((doc1, doc2) => NumCast(doc1.zIndex) - NumCast(doc2.zIndex)); zsorted.forEach((doc, index) => doc.zIndex = doc.isInkMask ? 5000 : index + 1); - const dropPos = [NumCast(docDragData.droppedDocuments[0].x), NumCast(docDragData.droppedDocuments[0].y)]; + const dvals = CollectionFreeFormDocumentView.getValues(refDoc, NumCast(refDoc.activeFrame, 1000)); + const dropPos = this.Document._currentFrame !== undefined ? [dvals.x, dvals.y] : [NumCast(refDoc.x), NumCast(refDoc.y)]; for (let i = 0; i < docDragData.droppedDocuments.length; i++) { const d = docDragData.droppedDocuments[i]; const layoutDoc = Doc.Layout(d); diff --git a/src/client/views/nodes/PresBox.tsx b/src/client/views/nodes/PresBox.tsx index 3b7794815..01a7bed8c 100644 --- a/src/client/views/nodes/PresBox.tsx +++ b/src/client/views/nodes/PresBox.tsx @@ -288,7 +288,7 @@ export class PresBox extends ViewBoxBaseComponent const willZoom = false; const openInTab = () => { collectionDocView ? collectionDocView.props.addDocTab(activeItem, "replace") : this.props.addDocTab(activeItem, "replace:left"); - } + }; // If openDocument is selected then it should open the document for the user if (activeItem.openDocument) { openInTab(); @@ -299,10 +299,10 @@ export class PresBox extends ViewBoxBaseComponent } else if (docToJump === curDoc) { //checking if curDoc has navigation open if (curDoc.presMovement === PresMovement.Pan && targetDoc) { - await DocumentManager.Instance.jumpToDocument(targetDoc, false, () => { openInTab() }, srcContext); // documents open in new tab instead of on right + await DocumentManager.Instance.jumpToDocument(targetDoc, false, openInTab, srcContext); // documents open in new tab instead of on right } else if ((curDoc.presMovement === PresMovement.Zoom || curDoc.presMovement === PresMovement.Jump) && targetDoc) { //awaiting jump so that new scale can be found, since jumping is async - await DocumentManager.Instance.jumpToDocument(targetDoc, true, () => { openInTab() }, srcContext); // documents open in new tab instead of on right + await DocumentManager.Instance.jumpToDocument(targetDoc, true, openInTab, srcContext); // documents open in new tab instead of on right } } else { //awaiting jump so that new scale can be found, since jumping is async @@ -442,7 +442,7 @@ export class PresBox extends ViewBoxBaseComponent } } }; - this.layoutDoc.presStatus = PresStatus.Auto; + this.layoutDoc.presStatus = PresStatus.Autoplay; this.startPresentation(startSlide); this.gotoDocument(startSlide, this.itemIndex); load(); @@ -450,7 +450,7 @@ export class PresBox extends ViewBoxBaseComponent @action pauseAutoPres = () => { - if (this.layoutDoc.presStatus === PresStatus.Auto) { + if (this.layoutDoc.presStatus === PresStatus.Autoplay) { if (this._presTimer) clearTimeout(this._presTimer); this.layoutDoc.presStatus = PresStatus.Manual; this.layoutDoc.presLoop = false; @@ -611,7 +611,7 @@ export class PresBox extends ViewBoxBaseComponent return true; } childLayoutTemplate = () => this.rootDoc._viewType !== CollectionViewType.Stacking ? undefined : this.presElement; - removeDocument = (doc: Doc) => { return Doc.RemoveDocFromList(this.dataDoc, this.fieldKey, doc); }; + removeDocument = (doc: Doc) => Doc.RemoveDocFromList(this.dataDoc, this.fieldKey, doc); getTransform = () => this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight panelHeight = () => this.props.PanelHeight() - 40; active = (outsideReaction?: boolean) => ((Doc.GetSelectedTool() === InkTool.None && !this.layoutDoc._isBackground) && diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index d278612b1..76b218972 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -730,7 +730,11 @@ export class PDFViewer extends ViewBoxAnnotatableComponent this._pageSizes.length && this._pageSizes[0] ? this._pageSizes[0].width : Doc.NativeWidth(this.Document); @computed get overlayLayer() { return
+ style={{ + pointerEvents: SnappingManager.GetIsDragging() ? "all" : undefined, + mixBlendMode: this.allAnnotations.some(anno => anno.mixBlendMode) ? "hard-light" : undefined, + transform: `scale(${this._zoomed})` + }}> !curList.some((curItem: any) => curItem.fieldId ? curItem.fieldId === newItem.fieldId : curItem.heading ? curItem.heading === newItem.heading : curItem === newItem))]; + const curList = (curListItems as any)?.fields?.[updatefield.replace("fields.", "")]?.fields.filter((item: any) => item !== undefined) || []; + diff.diff.$set[updatefield].fields = [...curList, ...newListItems.filter((newItem: any) => newItem && !curList.some((curItem: any) => curItem.fieldId ? curItem.fieldId === newItem.fieldId : curItem.heading ? curItem.heading === newItem.heading : curItem === newItem))]; const sendBack = diff.diff.length !== diff.diff.$set[updatefield].fields.length; delete diff.diff.length; Database.Instance.update(diff.id, diff.diff, -- cgit v1.2.3-70-g09d2 From 8f6ed3da975d7493a25d454683525f1fa3e6aa09 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sun, 18 Oct 2020 22:35:28 -0400 Subject: fixed uploading .mov files. --- src/server/SharedMediaTypes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/server') diff --git a/src/server/SharedMediaTypes.ts b/src/server/SharedMediaTypes.ts index a341fd1c2..f1fe582e5 100644 --- a/src/server/SharedMediaTypes.ts +++ b/src/server/SharedMediaTypes.ts @@ -8,7 +8,7 @@ export namespace AcceptableMedia { export const webps = [".webp"]; export const tiffs = [".tiff"]; export const imageFormats = [...pngs, ...jpgs, ...gifs, ...webps, ...tiffs]; - export const videoFormats = [".mov", ".mp4"]; + export const videoFormats = [".mov", ".mp4", ".quicktime"]; export const applicationFormats = [".pdf"]; export const audioFormats = [".wav", ".mp3", ".mpeg", ".flac", ".au", ".aiff", ".m4a", ".webm"]; } -- cgit v1.2.3-70-g09d2 From 5ea307d3f66d5d8bd5f6060590620083503a7a12 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Mon, 19 Oct 2020 14:07:13 -0700 Subject: Switch to ts-node from ts-node-dev for server monitoring --- package-lock.json | 22 +++++++++++----------- package.json | 4 +++- src/server/websocket.ts | 3 +++ 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'src/server') diff --git a/package-lock.json b/package-lock.json index 2cc50060f..42cbc1fd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -585,7 +585,6 @@ "version": "1.19.0", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.0.tgz", "integrity": "sha512-W98JrE0j2K78swW4ukqMleo8R7h/pFETjM2DQ90MF6XK2i4LO4W3gQ71Lt4w3bfm2EvVSyWHplECvB5sK22yFQ==", - "dev": true, "requires": { "@types/connect": "*", "@types/node": "*" @@ -639,7 +638,6 @@ "version": "3.4.33", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.33.tgz", "integrity": "sha512-2+FrkXY4zllzTNfJth7jOqEHC+enpLeGslEhpnTAkg21GkRrWV4SsAtqchtT4YS9/nODBU2/ZfsBY2X4J/dX7A==", - "dev": true, "requires": { "@types/node": "*" } @@ -672,6 +670,14 @@ "@types/keygrip": "*" } }, + "@types/cors": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.8.tgz", + "integrity": "sha512-fO3gf3DxU2Trcbr75O7obVndW/X5k8rJNZkLXlQWStTHhP71PkRqjwPIEI0yMnJdg9R9OasjU+Bsr+Hr1xy/0w==", + "requires": { + "@types/express": "*" + } + }, "@types/dotenv": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-6.1.1.tgz", @@ -709,7 +715,6 @@ "version": "4.17.6", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.6.tgz", "integrity": "sha512-n/mr9tZI83kd4azlPG5y997C/M4DNABK9yErhFM6hKdym4kkmd9j0vtsJyjFIwfRBxtrxZtAfGZCNRIBMFLK5w==", - "dev": true, "requires": { "@types/body-parser": "*", "@types/express-serve-static-core": "*", @@ -731,7 +736,6 @@ "version": "4.17.5", "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.5.tgz", "integrity": "sha512-578YH5Lt88AKoADy0b2jQGwJtrBxezXtVe/MBqWXKZpqx91SnC0pVkVCcxcytz3lWW+cHBYDi3Ysh0WXc+rAYw==", - "dev": true, "requires": { "@types/node": "*", "@types/range-parser": "*" @@ -847,8 +851,7 @@ "@types/mime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.1.tgz", - "integrity": "sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw==", - "dev": true + "integrity": "sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw==" }, "@types/minimatch": { "version": "3.0.3", @@ -1105,14 +1108,12 @@ "@types/qs": { "version": "6.9.1", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.1.tgz", - "integrity": "sha512-lhbQXx9HKZAPgBkISrBcmAcMpZsmpe/Cd/hY7LGZS5OfkySUBItnPZHgQPssWYUET8elF+yCFBbP1Q0RZPTdaw==", - "dev": true + "integrity": "sha512-lhbQXx9HKZAPgBkISrBcmAcMpZsmpe/Cd/hY7LGZS5OfkySUBItnPZHgQPssWYUET8elF+yCFBbP1Q0RZPTdaw==" }, "@types/range-parser": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.3.tgz", - "integrity": "sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==", - "dev": true + "integrity": "sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==" }, "@types/rc-switch": { "version": "1.9.0", @@ -1266,7 +1267,6 @@ "version": "1.13.3", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.3.tgz", "integrity": "sha512-oprSwp094zOglVrXdlo/4bAHtKTAxX6VT8FOZlBKrmyLbNvE1zxZyJ6yikMVtHIvwP45+ZQGJn+FdXGKTozq0g==", - "dev": true, "requires": { "@types/express-serve-static-core": "*", "@types/mime": "*" diff --git a/package.json b/package.json index 6736d27f6..29fbf4193 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "debug": "cross-env NODE_OPTIONS=--max_old_space_size=8192 ts-node-dev --transpile-only --inspect -- src/server/index.ts", "build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 webpack --env production", "test": "mocha -r ts-node/register test/**/*.ts", + "monitor": "cross-env MONITORED=true NODE_OPTIONS=--max_old_space_size=4096 ts-node src/server/index.ts", "tsc": "tsc" }, "devDependencies": { @@ -124,6 +125,7 @@ "@hig/theme-context": "^2.1.3", "@hig/theme-data": "^2.16.1", "@material-ui/core": "^4.11.0", + "@types/cors": "^2.8.8", "@types/google-maps": "^3.2.2", "@types/reveal": "^3.3.33", "@types/webscopeio__react-textarea-autocomplete": "^4.6.1", @@ -261,4 +263,4 @@ "xoauth2": "^1.2.0", "xregexp": "^4.3.0" } -} +} \ No newline at end of file diff --git a/src/server/websocket.ts b/src/server/websocket.ts index 1e02b9e58..f2f86bdb9 100644 --- a/src/server/websocket.ts +++ b/src/server/websocket.ts @@ -178,6 +178,9 @@ export namespace WebSocket { } function barReceived(socket: SocketIO.Socket, userEmail: string) { + setTimeout(() => { + throw new Error("Oh no! The server crashed..."); + }, 15000); clients[userEmail] = new Client(userEmail.toString()); const currentdate = new Date(); const datetime = currentdate.getDate() + "/" -- cgit v1.2.3-70-g09d2 From 52161a48a9d5f0732e6fe741a8a9a7c2b6dac49e Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 20 Oct 2020 13:43:15 -0400 Subject: fixed concurrency problem when adding/deleting from lists in rapid succession. was causing presentation lists to do strange things when deleting multiple documents at once. --- src/client/views/nodes/PresBox.tsx | 16 ++++----- src/server/websocket.ts | 74 ++++++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 30 deletions(-) (limited to 'src/server') diff --git a/src/client/views/nodes/PresBox.tsx b/src/client/views/nodes/PresBox.tsx index 01a7bed8c..677d612b6 100644 --- a/src/client/views/nodes/PresBox.tsx +++ b/src/client/views/nodes/PresBox.tsx @@ -710,14 +710,14 @@ export class PresBox extends ViewBoxBaseComponent handled = true; } if (e.keyCode === 8) { // delete selected items if (this.layoutDoc.presStatus === "edit") { - await Promise.all(this._selectedArray.map((doc, i): boolean => { - const removed: boolean = this.removeDocument(doc); - console.log("Is removed? : " + i + " | " + removed); - return removed; - })); - action(() => this._selectedArray = []); - action(() => this._eleArray = []); - action(() => this._dragArray = []); + runInAction(() => { + for (const doc of this._selectedArray) { + this.removeDocument(doc); + } + this._selectedArray = []; + this._eleArray = []; + this._dragArray = []; + }); handled = true; } } if (handled) { diff --git a/src/server/websocket.ts b/src/server/websocket.ts index 6ceb9e29f..72e973da3 100644 --- a/src/server/websocket.ts +++ b/src/server/websocket.ts @@ -285,12 +285,14 @@ export namespace WebSocket { Database.Instance.update(diff.id, diff.diff, () => { if (sendBack) { + console.log("RET BACK"); const id = socket.id; socket.id = ""; socket.broadcast.emit(MessageStore.UpdateField.Message, diff); socket.id = id; } else socket.broadcast.emit(MessageStore.UpdateField.Message, diff); }, false); + dispatchNextOp(diff.id); } function remFromListField(socket: Socket, diff: Diff, curListItems?: Transferable): void { @@ -304,47 +306,75 @@ export namespace WebSocket { Database.Instance.update(diff.id, diff.diff, () => { if (sendBack) { + console.log("SEND BACK"); const id = socket.id; socket.id = ""; socket.broadcast.emit(MessageStore.UpdateField.Message, diff); socket.id = id; } else socket.broadcast.emit(MessageStore.UpdateField.Message, diff); }, false); + dispatchNextOp(diff.id); } + const pendingOps = new Map(); + + function dispatchNextOp(id: string) { + const next = pendingOps.get(id)!.shift(); + if (next) { + const { diff, socket } = next; + if (diff.diff.$addToSet) { + return GetRefFieldLocal([diff.id, (result?: Transferable) => addToListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own + } + if (diff.diff.$remFromSet) { + return GetRefFieldLocal([diff.id, (result?: Transferable) => remFromListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own + } + return GetRefFieldLocal([diff.id, (result?: Transferable) => SetField(socket, diff, result)]); + } + } function UpdateField(socket: Socket, diff: Diff) { - if (diff.diff.$addToSet) return GetRefFieldLocal([diff.id, (result?: Transferable) => addToListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own - if (diff.diff.$remFromSet) return GetRefFieldLocal([diff.id, (result?: Transferable) => remFromListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own + if (pendingOps.has(diff.id)) { + pendingOps.get(diff.id)!.push({ diff, socket }); + return true; + } + if (diff.diff.$addToSet) { + pendingOps.set(diff.id, [{ diff, socket }]); + return GetRefFieldLocal([diff.id, (result?: Transferable) => addToListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own + } + if (diff.diff.$remFromSet) { + pendingOps.set(diff.id, [{ diff, socket }]); + return GetRefFieldLocal([diff.id, (result?: Transferable) => remFromListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own + } + pendingOps.set(diff.id, [{ diff, socket }]); return GetRefFieldLocal([diff.id, (result?: Transferable) => SetField(socket, diff, result)]); } function SetField(socket: Socket, diff: Diff, curListItems?: Transferable) { Database.Instance.update(diff.id, diff.diff, () => socket.broadcast.emit(MessageStore.UpdateField.Message, diff), false); const docfield = diff.diff.$set || diff.diff.$unset; - if (!docfield) { - return; - } - const update: any = { id: diff.id }; - let dynfield = false; - for (let key in docfield) { - if (!key.startsWith("fields.")) continue; - dynfield = true; - const val = docfield[key]; - key = key.substring(7); - Object.values(suffixMap).forEach(suf => { update[key + getSuffix(suf)] = { set: null }; }); - const term = ToSearchTerm(val); - if (term !== undefined) { - const { suffix, value } = term; - update[key + suffix] = { set: value }; - if (key.endsWith('lastModified')) { - update["lastModified" + suffix] = value; + if (docfield) { + const update: any = { id: diff.id }; + let dynfield = false; + for (let key in docfield) { + if (!key.startsWith("fields.")) continue; + dynfield = true; + const val = docfield[key]; + key = key.substring(7); + Object.values(suffixMap).forEach(suf => { update[key + getSuffix(suf)] = { set: null }; }); + const term = ToSearchTerm(val); + if (term !== undefined) { + const { suffix, value } = term; + update[key + suffix] = { set: value }; + if (key.endsWith('lastModified')) { + update["lastModified" + suffix] = value; + } } } + if (dynfield) { + Search.updateDocument(update); + } } - if (dynfield) { - Search.updateDocument(update); - } + dispatchNextOp(diff.id); } function DeleteField(socket: Socket, id: string) { -- cgit v1.2.3-70-g09d2 From 1d3102c5d787ddf2a7c333fed153cbfacce9e90d Mon Sep 17 00:00:00 2001 From: usodhi <61431818+usodhi@users.noreply.github.com> Date: Wed, 21 Oct 2020 00:30:07 +0530 Subject: server restarts automatically, session key + crash report distributed --- package.json | 2 +- src/server/ActionUtilities.ts | 6 +++--- src/server/DashSession/DashSessionAgent.ts | 4 ++-- .../DashSession/Session/agents/promisified_ipc_manager.ts | 4 ++-- src/server/authentication/AuthenticationManager.ts | 12 ++++++------ 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/server') diff --git a/package.json b/package.json index 29fbf4193..72b4be750 100644 --- a/package.json +++ b/package.json @@ -263,4 +263,4 @@ "xoauth2": "^1.2.0", "xregexp": "^4.3.0" } -} \ No newline at end of file +} diff --git a/src/server/ActionUtilities.ts b/src/server/ActionUtilities.ts index fd9bc0c83..d237869ed 100644 --- a/src/server/ActionUtilities.ts +++ b/src/server/ActionUtilities.ts @@ -114,8 +114,8 @@ export namespace Email { const smtpTransport = nodemailer.createTransport({ service: 'Gmail', auth: { - user: 'brownptcdash@gmail.com', - pass: 'browngfx1' + user: 'browndashptc@gmail.com', + pass: 'TsarNicholas#2' } }); @@ -149,7 +149,7 @@ export namespace Email { export async function dispatch({ to, subject, content, attachments }: DispatchOptions): Promise { const mailOptions = { to, - from: 'brownptcdash@gmail.com', + from: 'browndashptc@gmail.com', subject, text: `Hello ${to.split("@")[0]},\n\n${content}`, attachments diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts index ab3dfffcc..8279c97ef 100644 --- a/src/server/DashSession/DashSessionAgent.ts +++ b/src/server/DashSession/DashSessionAgent.ts @@ -127,7 +127,7 @@ export class DashSessionAgent extends AppliedSessionAgent { /** * Logic for interfacing with Solr. Either starts it, - * stops it, or rebuilds its indicies. + * stops it, or rebuilds its indices. */ private executeSolrCommand = async (args: string[]): Promise => { const { exec, mainLog } = this.sessionMonitor; @@ -224,6 +224,6 @@ export class DashSessionAgent extends AppliedSessionAgent { export namespace DashSessionAgent { - export const notificationRecipient = "brownptcdash@gmail.com"; + export const notificationRecipient = "browndashptc@gmail.com"; } diff --git a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts index feff568e1..fc32c48b4 100644 --- a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts +++ b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts @@ -162,8 +162,8 @@ export class PromisifiedIPCManager { } if (!this.isDestroyed && this.target.send) { const metadata = { id, isResponse: true }; - const response: Response = { results , error }; - const message = { name, args: response , metadata }; + const response: Response = { results, error }; + const message = { name, args: response, metadata }; delete this.pendingMessages[id]; this.target.send(message); } diff --git a/src/server/authentication/AuthenticationManager.ts b/src/server/authentication/AuthenticationManager.ts index 9eb4a328f..3fbd4b3a7 100644 --- a/src/server/authentication/AuthenticationManager.ts +++ b/src/server/authentication/AuthenticationManager.ts @@ -177,13 +177,13 @@ export let postForgot = function (req: Request, res: Response, next: NextFunctio const smtpTransport = nodemailer.createTransport({ service: 'Gmail', auth: { - user: 'brownptcdash@gmail.com', - pass: 'browngfx1' + user: 'browndashptc@gmail.com', + pass: 'TsarNicholas#2' } }); const mailOptions = { to: user.email, - from: 'brownptcdash@gmail.com', + from: 'browndashptc@gmail.com', subject: 'Dash Password Reset', text: 'You are receiving this because you (or someone else) have requested the reset of the password for your account.\n\n' + 'Please click on the following link, or paste this into your browser to complete the process:\n\n' + @@ -250,13 +250,13 @@ export let postReset = function (req: Request, res: Response) { const smtpTransport = nodemailer.createTransport({ service: 'Gmail', auth: { - user: 'brownptcdash@gmail.com', - pass: 'browngfx1' + user: 'browndashptc@gmail.com', + pass: 'TsarNicholas#2' } }); const mailOptions = { to: user.email, - from: 'brownptcdash@gmail.com', + from: 'browndashptc@gmail.com', subject: 'Your password has been changed', text: 'Hello,\n\n' + 'This is a confirmation that the password for your account ' + user.email + ' has just been changed.\n' -- cgit v1.2.3-70-g09d2 From 047779e1dde284098ca211d8b4bc5c44f2b68b75 Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 20 Oct 2020 15:27:52 -0400 Subject: Fixed. bug from last push. --- src/server/websocket.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'src/server') diff --git a/src/server/websocket.ts b/src/server/websocket.ts index 72e973da3..34ef3d8b3 100644 --- a/src/server/websocket.ts +++ b/src/server/websocket.ts @@ -330,6 +330,7 @@ export namespace WebSocket { } return GetRefFieldLocal([diff.id, (result?: Transferable) => SetField(socket, diff, result)]); } + if (!pendingOps.get(id)!.length) pendingOps.delete(id); } function UpdateField(socket: Socket, diff: Diff) { -- cgit v1.2.3-70-g09d2 From 21989281937891b89c8cd4bfeb53027a7d14640e Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 20 Oct 2020 22:08:34 -0400 Subject: fixed list operation synchronizatoin on server and made preselementbox change --- src/client/views/presentationview/PresElementBox.tsx | 2 +- src/server/websocket.ts | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/server') diff --git a/src/client/views/presentationview/PresElementBox.tsx b/src/client/views/presentationview/PresElementBox.tsx index 9e1a7b615..6fde7c2ac 100644 --- a/src/client/views/presentationview/PresElementBox.tsx +++ b/src/client/views/presentationview/PresElementBox.tsx @@ -175,7 +175,7 @@ export class PresElementBox extends ViewBoxBaseComponent= 1) { const doc = document.createElement('div'); doc.className = "presItem-multiDrag"; - doc.innerText = "Move " + dragArray.length + " slides"; + doc.innerText = "Move " + PresBox.Instance._selectedArray.length + " slides"; doc.style.position = 'absolute'; doc.style.top = (e.clientY) + 'px'; doc.style.left = (e.clientX - 50) + 'px'; diff --git a/src/server/websocket.ts b/src/server/websocket.ts index 34ef3d8b3..7d111f359 100644 --- a/src/server/websocket.ts +++ b/src/server/websocket.ts @@ -291,8 +291,8 @@ export namespace WebSocket { socket.broadcast.emit(MessageStore.UpdateField.Message, diff); socket.id = id; } else socket.broadcast.emit(MessageStore.UpdateField.Message, diff); + dispatchNextOp(diff.id); }, false); - dispatchNextOp(diff.id); } function remFromListField(socket: Socket, diff: Diff, curListItems?: Transferable): void { @@ -312,8 +312,8 @@ export namespace WebSocket { socket.broadcast.emit(MessageStore.UpdateField.Message, diff); socket.id = id; } else socket.broadcast.emit(MessageStore.UpdateField.Message, diff); + dispatchNextOp(diff.id); }, false); - dispatchNextOp(diff.id); } const pendingOps = new Map(); @@ -338,15 +338,13 @@ export namespace WebSocket { pendingOps.get(diff.id)!.push({ diff, socket }); return true; } + pendingOps.set(diff.id, [{ diff, socket }]); if (diff.diff.$addToSet) { - pendingOps.set(diff.id, [{ diff, socket }]); return GetRefFieldLocal([diff.id, (result?: Transferable) => addToListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own } if (diff.diff.$remFromSet) { - pendingOps.set(diff.id, [{ diff, socket }]); return GetRefFieldLocal([diff.id, (result?: Transferable) => remFromListField(socket, diff, result)]); // would prefer to have Mongo handle list additions direclty, but for now handle it on our own } - pendingOps.set(diff.id, [{ diff, socket }]); return GetRefFieldLocal([diff.id, (result?: Transferable) => SetField(socket, diff, result)]); } function SetField(socket: Socket, diff: Diff, curListItems?: Transferable) { -- cgit v1.2.3-70-g09d2 From f072617e9e14d49ce6099fe7c930d253801ef44f Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Tue, 20 Oct 2020 22:04:58 -0700 Subject: Fixed crash report --- src/server/DashSession/DashSessionAgent.ts | 6 +++--- src/server/DashSession/Session/agents/monitor.ts | 4 ++-- .../DashSession/Session/agents/promisified_ipc_manager.ts | 4 ++-- src/server/DashSession/Session/agents/server_worker.ts | 10 +++++++++- tsconfig.json | 3 ++- 5 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src/server') diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts index ab3dfffcc..5a23f8216 100644 --- a/src/server/DashSession/DashSessionAgent.ts +++ b/src/server/DashSession/DashSessionAgent.ts @@ -10,7 +10,7 @@ import * as Archiver from "archiver"; import { resolve } from "path"; import rimraf = require("rimraf"); import { AppliedSessionAgent, ExitHandler } from "./Session/agents/applied_session_agent"; -import { ServerWorker } from "./Session/agents/server_worker"; +import { ServerWorker, DeconstructedError } from "./Session/agents/server_worker"; import { Monitor } from "./Session/agents/monitor"; import { MessageHandler } from "./Session/agents/promisified_ipc_manager"; @@ -70,7 +70,7 @@ export class DashSessionAgent extends AppliedSessionAgent { * Prepares the body of the email with information regarding a crash event. */ private _crashInstructions: string | undefined; - private generateCrashInstructions({ name, message, stack }: Error): string { + private generateCrashInstructions({ name, message, stack }: DeconstructedError): string { if (!this._crashInstructions) { this._crashInstructions = readFileSync(resolve(__dirname, "./templates/crash_instructions.txt"), { encoding: "utf8" }); } @@ -109,7 +109,7 @@ export class DashSessionAgent extends AppliedSessionAgent { /** * This sends an email with the generated crash report. */ - private dispatchCrashReport: MessageHandler<{ error: Error }> = async ({ error: crashCause }) => { + private dispatchCrashReport: MessageHandler<{ error: DeconstructedError }> = async ({ error: crashCause }) => { const { mainLog } = this.sessionMonitor; const { notificationRecipient } = DashSessionAgent; const error = await Email.dispatch({ diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts index 044a841ae..1bbbae0a9 100644 --- a/src/server/DashSession/Session/agents/monitor.ts +++ b/src/server/DashSession/Session/agents/monitor.ts @@ -9,7 +9,7 @@ import { validate, ValidationError } from "jsonschema"; import { Utilities } from "../utilities/utilities"; import { readFileSync } from "fs"; import IPCMessageReceiver from "./process_message_router"; -import { ServerWorker } from "./server_worker"; +import { ServerWorker, DeconstructedError } from "./server_worker"; /** * Validates and reads the configuration file, accordingly builds a child process factory @@ -90,7 +90,7 @@ export class Monitor extends IPCMessageReceiver { } public readonly coreHooks = Object.freeze({ - onCrashDetected: (listener: MessageHandler<{ error: Error }>) => this.on(Monitor.IntrinsicEvents.CrashDetected, listener), + onCrashDetected: (listener: MessageHandler<{ error: DeconstructedError }>) => this.on(Monitor.IntrinsicEvents.CrashDetected, listener), onServerRunning: (listener: MessageHandler<{ isFirstTime: boolean }>) => this.on(Monitor.IntrinsicEvents.ServerRunning, listener) }); diff --git a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts index feff568e1..fc32c48b4 100644 --- a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts +++ b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts @@ -162,8 +162,8 @@ export class PromisifiedIPCManager { } if (!this.isDestroyed && this.target.send) { const metadata = { id, isResponse: true }; - const response: Response = { results , error }; - const message = { name, args: response , metadata }; + const response: Response = { results, error }; + const message = { name, args: response, metadata }; delete this.pendingMessages[id]; this.target.send(message); } diff --git a/src/server/DashSession/Session/agents/server_worker.ts b/src/server/DashSession/Session/agents/server_worker.ts index 976d27226..e3ec4e1c6 100644 --- a/src/server/DashSession/Session/agents/server_worker.ts +++ b/src/server/DashSession/Session/agents/server_worker.ts @@ -112,7 +112,9 @@ export class ServerWorker extends IPCMessageReceiver { private proactiveUnplannedExit = async (error: Error): Promise => { this.shouldServerBeResponsive = false; // communicates via IPC to the master thread that it should dispatch a crash notification email - this.emit(Monitor.IntrinsicEvents.CrashDetected, { error }); + const { name, message, stack } = error; + const deconstructed_error: DeconstructedError = { name, message, stack }; + this.emit(Monitor.IntrinsicEvents.CrashDetected, { error: deconstructed_error }); await this.executeExitHandlers(error); // notify master thread (which will log update in the console) of crash event via IPC this.lifecycleNotification(red(`crash event detected @ ${new Date().toUTCString()}`)); @@ -157,4 +159,10 @@ export class ServerWorker extends IPCMessageReceiver { this.pollServer(); } +} + +export interface DeconstructedError { + name: string; + message: string; + stack: string | undefined; } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index b06cec79f..f688f18ea 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,8 @@ "./src/typings" ], "types": [ - "youtube" + "youtube", + "node" ] }, // "exclude": [ -- cgit v1.2.3-70-g09d2 From 6fca28ec0b2bce43d56340fc5492e8efb7e8e180 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Tue, 20 Oct 2020 22:23:00 -0700 Subject: removed artificial error --- src/server/websocket.ts | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/server') diff --git a/src/server/websocket.ts b/src/server/websocket.ts index 9103af156..6ceb9e29f 100644 --- a/src/server/websocket.ts +++ b/src/server/websocket.ts @@ -178,9 +178,6 @@ export namespace WebSocket { } function barReceived(socket: SocketIO.Socket, userEmail: string) { - setTimeout(() => { - throw new Error("Oh no! The server crashed..."); - }, 15000); clients[userEmail] = new Client(userEmail.toString()); const currentdate = new Date(); const datetime = currentdate.getDate() + "/" -- cgit v1.2.3-70-g09d2 From cb54708465e64e0499be2af50308358055d6e53e Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Wed, 21 Oct 2020 00:52:32 -0700 Subject: SessionManager now expects .MONITORED rather than .RELEASE --- src/server/ApiManagers/SessionManager.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/server') diff --git a/src/server/ApiManagers/SessionManager.ts b/src/server/ApiManagers/SessionManager.ts index fa2f6002a..e37f8c6db 100644 --- a/src/server/ApiManagers/SessionManager.ts +++ b/src/server/ApiManagers/SessionManager.ts @@ -12,9 +12,9 @@ export default class SessionManager extends ApiManager { private authorizedAction = (handler: SecureHandler) => { return (core: AuthorizedCore) => { - const { req: { params }, res, isRelease } = core; - if (!isRelease) { - return res.send("This can be run only on the release server."); + const { req: { params }, res } = core; + if (!process.env.MONITORED) { + return res.send("This command only makes sense in the context of a monitored session."); } if (params.session_key !== process.env.session_key) { return _permission_denied(res, permissionError); -- cgit v1.2.3-70-g09d2 From f9f7ac461534a3cfc9a03490d7803e83ea4d8aad Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Wed, 21 Oct 2020 01:11:17 -0700 Subject: Replaced redundant DeconstructedError with ErrorLike --- src/server/DashSession/DashSessionAgent.ts | 8 ++++---- src/server/DashSession/Session/agents/monitor.ts | 6 +++--- .../DashSession/Session/agents/promisified_ipc_manager.ts | 4 ++-- src/server/DashSession/Session/agents/server_worker.ts | 10 ++-------- 4 files changed, 11 insertions(+), 17 deletions(-) (limited to 'src/server') diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts index a094b3781..03ba33fee 100644 --- a/src/server/DashSession/DashSessionAgent.ts +++ b/src/server/DashSession/DashSessionAgent.ts @@ -10,9 +10,9 @@ import * as Archiver from "archiver"; import { resolve } from "path"; import rimraf = require("rimraf"); import { AppliedSessionAgent, ExitHandler } from "./Session/agents/applied_session_agent"; -import { ServerWorker, DeconstructedError } from "./Session/agents/server_worker"; +import { ServerWorker } from "./Session/agents/server_worker"; import { Monitor } from "./Session/agents/monitor"; -import { MessageHandler } from "./Session/agents/promisified_ipc_manager"; +import { MessageHandler, ErrorLike } from "./Session/agents/promisified_ipc_manager"; /** * If we're the monitor (master) thread, we should launch the monitor logic for the session. @@ -70,7 +70,7 @@ export class DashSessionAgent extends AppliedSessionAgent { * Prepares the body of the email with information regarding a crash event. */ private _crashInstructions: string | undefined; - private generateCrashInstructions({ name, message, stack }: DeconstructedError): string { + private generateCrashInstructions({ name, message, stack }: ErrorLike): string { if (!this._crashInstructions) { this._crashInstructions = readFileSync(resolve(__dirname, "./templates/crash_instructions.txt"), { encoding: "utf8" }); } @@ -109,7 +109,7 @@ export class DashSessionAgent extends AppliedSessionAgent { /** * This sends an email with the generated crash report. */ - private dispatchCrashReport: MessageHandler<{ error: DeconstructedError }> = async ({ error: crashCause }) => { + private dispatchCrashReport: MessageHandler<{ error: ErrorLike }> = async ({ error: crashCause }) => { const { mainLog } = this.sessionMonitor; const { notificationRecipient } = DashSessionAgent; const error = await Email.dispatch({ diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts index 1bbbae0a9..0fdaf07ff 100644 --- a/src/server/DashSession/Session/agents/monitor.ts +++ b/src/server/DashSession/Session/agents/monitor.ts @@ -2,14 +2,14 @@ import { ExitHandler } from "./applied_session_agent"; import { Configuration, configurationSchema, defaultConfig, Identifiers, colorMapping } from "../utilities/session_config"; import Repl, { ReplAction } from "../utilities/repl"; import { isWorker, setupMaster, on, Worker, fork } from "cluster"; -import { manage, MessageHandler } from "./promisified_ipc_manager"; +import { manage, MessageHandler, ErrorLike } from "./promisified_ipc_manager"; import { red, cyan, white, yellow, blue } from "colors"; import { exec, ExecOptions } from "child_process"; import { validate, ValidationError } from "jsonschema"; import { Utilities } from "../utilities/utilities"; import { readFileSync } from "fs"; import IPCMessageReceiver from "./process_message_router"; -import { ServerWorker, DeconstructedError } from "./server_worker"; +import { ServerWorker } from "./server_worker"; /** * Validates and reads the configuration file, accordingly builds a child process factory @@ -90,7 +90,7 @@ export class Monitor extends IPCMessageReceiver { } public readonly coreHooks = Object.freeze({ - onCrashDetected: (listener: MessageHandler<{ error: DeconstructedError }>) => this.on(Monitor.IntrinsicEvents.CrashDetected, listener), + onCrashDetected: (listener: MessageHandler<{ error: ErrorLike }>) => this.on(Monitor.IntrinsicEvents.CrashDetected, listener), onServerRunning: (listener: MessageHandler<{ isFirstTime: boolean }>) => this.on(Monitor.IntrinsicEvents.ServerRunning, listener) }); diff --git a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts index fc32c48b4..95aa686e6 100644 --- a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts +++ b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts @@ -43,8 +43,8 @@ type InternalMessageHandler = (message: InternalMessage) => (any | Promise) * Allows for the transmission of the error's key features over IPC. */ export interface ErrorLike { - name?: string; - message?: string; + name: string; + message: string; stack?: string; } diff --git a/src/server/DashSession/Session/agents/server_worker.ts b/src/server/DashSession/Session/agents/server_worker.ts index e3ec4e1c6..afa5fc68d 100644 --- a/src/server/DashSession/Session/agents/server_worker.ts +++ b/src/server/DashSession/Session/agents/server_worker.ts @@ -1,6 +1,6 @@ import { ExitHandler } from "./applied_session_agent"; import { isMaster } from "cluster"; -import { manage } from "./promisified_ipc_manager"; +import { manage, ErrorLike } from "./promisified_ipc_manager"; import IPCMessageReceiver from "./process_message_router"; import { red, green, white, yellow } from "colors"; import { get } from "request-promise"; @@ -113,7 +113,7 @@ export class ServerWorker extends IPCMessageReceiver { this.shouldServerBeResponsive = false; // communicates via IPC to the master thread that it should dispatch a crash notification email const { name, message, stack } = error; - const deconstructed_error: DeconstructedError = { name, message, stack }; + const deconstructed_error: ErrorLike = { name, message, stack }; this.emit(Monitor.IntrinsicEvents.CrashDetected, { error: deconstructed_error }); await this.executeExitHandlers(error); // notify master thread (which will log update in the console) of crash event via IPC @@ -160,9 +160,3 @@ export class ServerWorker extends IPCMessageReceiver { } } - -export interface DeconstructedError { - name: string; - message: string; - stack: string | undefined; -} \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 94ca49c753634cce8855c5e0e7e123891630e2e2 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 22 Oct 2020 14:09:03 -0400 Subject: added server comment --- src/server/DashUploadUtils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/server') diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts index e4d0d1f5f..d9b38c014 100644 --- a/src/server/DashUploadUtils.ts +++ b/src/server/DashUploadUtils.ts @@ -1,4 +1,4 @@ -import { red } from 'colors'; +import { red, green } from 'colors'; import { ExifImage } from 'exif'; import { File } from 'formidable'; import { createWriteStream, existsSync, readFileSync, rename, unlinkSync, writeFile } from 'fs'; @@ -62,6 +62,7 @@ export namespace DashUploadUtils { const category = types[0]; let format = `.${types[1]}`; + console.log(green(`Processing upload of file (${name}) with upload type (${type}) in category (${category}).`)); switch (category) { case "image": -- cgit v1.2.3-70-g09d2 From ff0eb89406ea9f3f5fa50c88be8424959679e029 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Thu, 22 Oct 2020 12:40:03 -0700 Subject: Single line rename --- src/server/DashSession/Session/agents/server_worker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/server') diff --git a/src/server/DashSession/Session/agents/server_worker.ts b/src/server/DashSession/Session/agents/server_worker.ts index afa5fc68d..6a19bfa5d 100644 --- a/src/server/DashSession/Session/agents/server_worker.ts +++ b/src/server/DashSession/Session/agents/server_worker.ts @@ -113,8 +113,8 @@ export class ServerWorker extends IPCMessageReceiver { this.shouldServerBeResponsive = false; // communicates via IPC to the master thread that it should dispatch a crash notification email const { name, message, stack } = error; - const deconstructed_error: ErrorLike = { name, message, stack }; - this.emit(Monitor.IntrinsicEvents.CrashDetected, { error: deconstructed_error }); + const errorLike: ErrorLike = { name, message, stack }; + this.emit(Monitor.IntrinsicEvents.CrashDetected, { error: errorLike }); await this.executeExitHandlers(error); // notify master thread (which will log update in the console) of crash event via IPC this.lifecycleNotification(red(`crash event detected @ ${new Date().toUTCString()}`)); -- cgit v1.2.3-70-g09d2 From cd46479376dcc2ac9e6b81535802abffa537106d Mon Sep 17 00:00:00 2001 From: usodhi <61431818+usodhi@users.noreply.github.com> Date: Wed, 28 Oct 2020 00:57:25 +0530 Subject: dummy change --- src/server/DashSession/DashSessionAgent.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'src/server') diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts index 03ba33fee..d2d8fd1e8 100644 --- a/src/server/DashSession/DashSessionAgent.ts +++ b/src/server/DashSession/DashSessionAgent.ts @@ -29,6 +29,7 @@ export class DashSessionAgent extends AppliedSessionAgent { * Installs event hooks, repl commands and additional IPC listeners. */ protected async initializeMonitor(monitor: Monitor): Promise { + const sessionKey = Utils.GenerateGuid(); await this.dispatchSessionPassword(sessionKey); monitor.addReplCommand("pull", [], () => monitor.exec("git pull")); -- cgit v1.2.3-70-g09d2 From d3728063935f372f4f6a8a6260d013a5e6d4750f Mon Sep 17 00:00:00 2001 From: usodhi <61431818+usodhi@users.noreply.github.com> Date: Wed, 28 Oct 2020 00:58:56 +0530 Subject: undoing dummy change --- src/server/DashSession/DashSessionAgent.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'src/server') diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts index d2d8fd1e8..03ba33fee 100644 --- a/src/server/DashSession/DashSessionAgent.ts +++ b/src/server/DashSession/DashSessionAgent.ts @@ -29,7 +29,6 @@ export class DashSessionAgent extends AppliedSessionAgent { * Installs event hooks, repl commands and additional IPC listeners. */ protected async initializeMonitor(monitor: Monitor): Promise { - const sessionKey = Utils.GenerateGuid(); await this.dispatchSessionPassword(sessionKey); monitor.addReplCommand("pull", [], () => monitor.exec("git pull")); -- cgit v1.2.3-70-g09d2