Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into azure-openai-integrat…
Browse files Browse the repository at this point in the history
…ion-server-side-3
  • Loading branch information
Steve-KX-RL committed Apr 10, 2024
2 parents b0cc710 + 8cd5859 commit e4e0652
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 68 deletions.
2 changes: 1 addition & 1 deletion libraries/objectDefaultFiles/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
/**
* Helper function that tools can use to convert a path on the server to the correct server's URL,
* @example input: '/object/test/uploadMediaFile'
* output: 'https://toolboxedge.net/n/id/s/id/object/test/uploadMediaFile' on cloud server
* output: 'https://spatial.ptc.io/n/id/s/id/object/test/uploadMediaFile' on cloud server
* output: 'http://192.168.0.25:8080/object/test/uploadMediaFile' on local server
* @param {string} path
* @returns {string}
Expand Down
4 changes: 2 additions & 2 deletions libraries/serverHelpers/proxyRequestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const https = require('https');
const proxyRequestHandler = (req, res) => {
const input = req.params[0];
if (!input.includes('://')) {
const proxyURL = `https://toolboxedge.net/${req.params[0]}`;
const proxyURL = `https://spatial.ptc.io/${req.params[0]}`;
const headers = req.headers;
headers.Host = "toolboxedge.net";
headers.Host = 'spatial.ptc.io';
https.get(proxyURL, {headers}, proxyRes => {
res.status(proxyRes.statusCode);
for (let header in proxyRes.headers) {
Expand Down
120 changes: 59 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"jsdoc": "^4.0.2",
"minami": "^1.2.3",
"mock-fs": "^5.2.0",
"puppeteer": "^22.6.1"
"puppeteer": "^22.6.3"
},
"scripts": {
"test": "npm run lint && jest --forceExit --runInBand",
Expand Down
2 changes: 1 addition & 1 deletion persistence/CloudProxyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class CloudProxyWrapper {
if (!edgeAgent || !edgeAgent.networkUUID || !edgeAgent.networkSecret) {
throw new Error('bad edge-agent settings: ' + JSON.stringify(edgeAgent));
}
const serverUrl = edgeAgent.serverUrl || 'alpha.toolboxedge.net';
const serverUrl = edgeAgent.serverUrl || 'alpha.spatial.ptc.io';
const networkUUID = edgeAgent.networkUUID;
const networkSecret = edgeAgent.networkSecret;
return `https://${serverUrl}/n/${networkUUID}/s/${networkSecret}/files/`;
Expand Down
18 changes: 17 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ const globalVariables = {

exports.useHTTPS = globalVariables.useHTTPS;

let forceGCInterval = null;
if (global.gc) {
setInterval(() => {
const usage = process.memoryUsage();
// Total memory usage less than 100 MB
if (!usage || usage.rss < 100 * 1024 * 1024) {
return;
}

global.gc();
}, 7919); // arbitrary prime number delay to distribute around the gc hitches
}

// ports used to define the server behaviour
/*
The server uses port 8080 to communicate with other servers and with the Reality Editor.
Expand Down Expand Up @@ -1179,6 +1192,9 @@ async function exit() {
console.warn('unable to close udpServer', e);
}
clearInterval(socketUpdaterInterval);
if (forceGCInterval) {
clearInterval(forceGCInterval);
}
staleObjectCleaner.clearCleanupIntervals();
humanPoseFuser.stop();
for (const splatTask of Object.values(splatTasks)) {
Expand Down Expand Up @@ -2324,7 +2340,7 @@ function objectWebServer() {
res.send(webFrontend.generateHtmlForHardwareInterface(req.params.interfaceName, hardwareInterfaceModules, version, services.ips, serverPort, globalVariables.useHTTPS, configHtmlPath));
});

// Proxies requests to toolboxedge.net, for CORS video playback
// Proxies requests to spatial.ptc.io, for CORS video playback
const proxyRequestHandler = require('./libraries/serverHelpers/proxyRequestHandler.js');
webServer.get('/proxy/*', proxyRequestHandler);

Expand Down

0 comments on commit e4e0652

Please sign in to comment.