volume path

This commit is contained in:
Koushik Dutta
2021-09-09 17:48:39 -07:00
parent 5c510c4ba1
commit 5a248572fd
7 changed files with 71 additions and 55 deletions

1
server/.gitignore vendored
View File

@@ -2,6 +2,7 @@ node_modules
.DS_Store
.gcloud/
dist/
volume
scrypted.db
out
scrypted.db.bak

View File

@@ -28,6 +28,7 @@
"level": "^6.0.1",
"lodash": "^4.17.21",
"memfs": "^3.2.2",
"mkdirp": "^1.0.4",
"node-dijkstra": "^2.5.0",
"pem": "^1.14.4",
"query-string": "^6.14.1",
@@ -42,6 +43,7 @@
},
"devDependencies": {
"@types/lodash": "^4.14.168",
"@types/mkdirp": "^1.0.2",
"@types/tar": "^4.0.5",
"@types/tmp": "^0.2.0",
"@types/whatwg-mimetype": "^2.1.0",
@@ -531,6 +533,15 @@
"@types/node": "*"
}
},
"node_modules/@types/mkdirp": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@types/mkdirp/-/mkdirp-1.0.2.tgz",
"integrity": "sha512-o0K1tSO0Dx5X6xlU5F1D6625FawhC3dU3iqr25lluNv/+/QIVH8RLNEiVokgIZo+mz+87w/3Mkg/VvQS+J51fQ==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/node": {
"version": "14.14.31",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.31.tgz",
@@ -1491,17 +1502,6 @@
"tar": "^6.0.1"
}
},
"node_modules/ffmpeg-for-homebridge/node_modules/mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"bin": {
"mkdirp": "bin/cmd.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
@@ -2195,14 +2195,14 @@
}
},
"node_modules/mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"dependencies": {
"minimist": "^1.2.5"
},
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"bin": {
"mkdirp": "bin/cmd.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/mkdirp-classic": {
@@ -2343,6 +2343,17 @@
"minipass": "^2.9.0"
}
},
"node_modules/node-pre-gyp/node_modules/mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"dependencies": {
"minimist": "^1.2.5"
},
"bin": {
"mkdirp": "bin/cmd.js"
}
},
"node_modules/node-pre-gyp/node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
@@ -3070,17 +3081,6 @@
"node": ">=10"
}
},
"node_modules/tar/node_modules/mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"bin": {
"mkdirp": "bin/cmd.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/text-hex": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
@@ -3807,6 +3807,15 @@
"@types/node": "*"
}
},
"@types/mkdirp": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@types/mkdirp/-/mkdirp-1.0.2.tgz",
"integrity": "sha512-o0K1tSO0Dx5X6xlU5F1D6625FawhC3dU3iqr25lluNv/+/QIVH8RLNEiVokgIZo+mz+87w/3Mkg/VvQS+J51fQ==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/node": {
"version": "14.14.31",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.31.tgz",
@@ -4592,13 +4601,6 @@
"mkdirp": "^1.0.3",
"simple-get": "^3.1.0",
"tar": "^6.0.1"
},
"dependencies": {
"mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
}
}
},
"file-uri-to-path": {
@@ -5163,12 +5165,9 @@
}
},
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"requires": {
"minimist": "^1.2.5"
}
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
},
"mkdirp-classic": {
"version": "0.5.3",
@@ -5290,6 +5289,14 @@
"minipass": "^2.9.0"
}
},
"mkdirp": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"requires": {
"minimist": "^1.2.5"
}
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
@@ -5828,11 +5835,6 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
"integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ=="
},
"mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw=="
}
}
},

View File

@@ -22,6 +22,7 @@
"level": "^6.0.1",
"lodash": "^4.17.21",
"memfs": "^3.2.2",
"mkdirp": "^1.0.4",
"node-dijkstra": "^2.5.0",
"pem": "^1.14.4",
"query-string": "^6.14.1",
@@ -39,6 +40,7 @@
},
"devDependencies": {
"@types/lodash": "^4.14.168",
"@types/mkdirp": "^1.0.2",
"@types/tar": "^4.0.5",
"@types/tmp": "^0.2.0",
"@types/whatwg-mimetype": "^2.1.0",

View File

@@ -1,12 +1,12 @@
import cluster from 'cluster';
import { RpcMessage, RpcPeer } from '../rpc';
import AdmZip from 'adm-zip';
import { ScryptedDevice, Device, DeviceManifest, EventDetails, EventListenerOptions, EventListenerRegister, EngineIOHandler, ScryptedInterfaceProperty, MediaManager, SystemDeviceState, HttpRequest } from '@scrypted/sdk/types'
import { Device, EventListenerRegister, EngineIOHandler, ScryptedInterfaceProperty, SystemDeviceState } from '@scrypted/sdk/types'
import { ScryptedRuntime } from '../runtime';
import { Plugin } from '../db-types';
import io from 'engine.io';
import { attachPluginRemote, setupPluginRemote } from './plugin-remote';
import { PluginAPI, PluginRemote } from './plugin-api';
import { PluginRemote } from './plugin-api';
import { Logger } from '../logger';
import { MediaManagerImpl } from './media';
import { getState } from '../state';
@@ -19,6 +19,8 @@ import { PassThrough } from 'stream';
import { Console } from 'console'
import { sleep } from '../sleep';
import { PluginHostAPI } from './plugin-host-api';
import mkdirp from 'mkdirp';
import path from 'path';
export class PluginHost {
worker: cluster.Worker;
@@ -80,7 +82,16 @@ export class PluginHost {
const logger = scrypted.getDeviceLogger(scrypted.findPluginDevice(plugin._id));
if (true) {
this.startPluginClusterHost(logger);
const cwd = path.join(process.cwd(), 'volume', 'plugins', this.pluginId);
try {
mkdirp.sync(cwd);
}
catch (e) {
}
this.startPluginClusterHost(logger, {
SCRYPTED_PLUGIN_VOLUME: cwd,
});
}
else {
const remote = new RpcPeer((message, reject) => {
@@ -194,8 +205,8 @@ export class PluginHost {
});
}
startPluginClusterHost(logger: Logger) {
this.worker = cluster.fork();
startPluginClusterHost(logger: Logger,env?: any) {
this.worker = cluster.fork(env);
this.worker.process.stdout.on('data', data => {
process.stdout.write(data);
@@ -428,9 +439,9 @@ class LazyRemote implements PluginRemote {
remote: PluginRemote;
constructor(init: Promise<PluginRemote>) {
this.init = (async() => {
this.init = (async () => {
this.remote = await init;
return this. remote;
return this.remote;
})();
}

View File

@@ -1,7 +1,7 @@
import AdmZip from 'adm-zip';
import { Volume } from 'memfs';
import path from 'path';
import { DeviceManager, Logger, Device, DeviceManifest, DeviceState, EventDetails, EventListenerOptions, EventListenerRegister, EndpointManager, SystemDeviceState, ScryptedStatic, SystemManager, MediaManager, ScryptedMimeTypes, ScryptedInterface, ScryptedInterfaceProperty, HttpRequest } from '@scrypted/sdk/types'
import { DeviceManager, Logger, Device, DeviceManifest, DeviceState, EndpointManager, SystemDeviceState, ScryptedStatic, SystemManager, MediaManager, ScryptedMimeTypes, ScryptedInterface, ScryptedInterfaceProperty, HttpRequest } from '@scrypted/sdk/types'
import { getIpAddress, SCRYPTED_INSECURE_PORT, SCRYPTED_SECURE_PORT } from '../server-settings';
import { PluginAPI, PluginLogger, PluginRemote } from './plugin-api';
import { SystemManagerImpl } from './system';

View File

@@ -77,7 +77,7 @@ else {
}
async function start() {
const db = level(path.join(process.cwd(), 'scrypted.db'));
const db = level(path.join(process.cwd(), 'volume', 'scrypted.db'));
await db.open();
let certSetting = await db.tryGet(Settings, 'certificate') as Settings;