Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit d9f8081

Browse files
authored
Fix local file server shutdown (#9312)
1 parent 21618f9 commit d9f8081

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

packages/server-core/src/media/storageprovider/local.storage.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { MULTIPART_CUTOFF_SIZE } from '@etherealengine/common/src/constants/File
3434

3535
import { FileBrowserContentType } from '@etherealengine/engine/src/schemas/media/file-browser.schema'
3636
import { getState } from '@etherealengine/hyperflux'
37+
import { ChildProcess } from 'child_process'
3738
import logger from '../../ServerLogger'
3839
import { ServerMode, ServerState } from '../../ServerState'
3940
import config from '../../appconfig'
@@ -81,9 +82,30 @@ export class LocalStorage implements StorageProviderInterface {
8182
this._store = fsStore(this.PATH_PREFIX)
8283

8384
if (getState(ServerState).serverMode === ServerMode.API && !config.testEnabled) {
84-
require('child_process').spawn('npm', ['run', 'serve-local-files'], {
85-
cwd: process.cwd(),
86-
stdio: 'inherit'
85+
const child: ChildProcess = require('child_process').spawn(
86+
'npx',
87+
[
88+
'http-server',
89+
`${this.PATH_PREFIX}`,
90+
'--ssl',
91+
'--cert',
92+
`${config.server.certPath}`,
93+
'--key',
94+
`${config.server.keyPath}`,
95+
'--port',
96+
'8642',
97+
'--cors=*',
98+
'--brotli',
99+
'--gzip'
100+
],
101+
{
102+
cwd: process.cwd(),
103+
stdio: 'inherit',
104+
detached: true
105+
}
106+
)
107+
process.on('exit', async () => {
108+
process.kill(-child.pid!, 'SIGINT')
87109
})
88110
}
89111
this.getOriginURLs().then((result) => (this.originURLs = result))

0 commit comments

Comments
 (0)