-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to bring back fileserver (#106)
* Changes to bring back fileserver * Bumped version to 0.3.3
- Loading branch information
1 parent
0238061
commit b32ff55
Showing
11 changed files
with
157 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
#=========== | ||
# Parameters | ||
#=========== | ||
|
||
while getopts f: flag; do | ||
case "${flag}" in | ||
f) ENGINE_FOLDER=${OPTARG} ;; | ||
*) | ||
echo "Invalid arguments passed" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [[ -z $ENGINE_FOLDER ]]; then | ||
echo "Missing arguments" | ||
exit 1 | ||
fi | ||
|
||
#========================= | ||
# Verify Local File Server | ||
#========================= | ||
|
||
if lsof -Pi :8642 -sTCP:LISTEN -t >/dev/null; then | ||
echo "file server is configured" | ||
lsof -Pi :8642 -sTCP:LISTEN | ||
else | ||
echo "file server is not configured" | ||
|
||
cd "$ENGINE_FOLDER"/packages/server | ||
|
||
npm run serve-local-files | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { app, BrowserWindow } from 'electron' | ||
import path from 'path' | ||
import { kill } from 'ps-node' | ||
|
||
import Channels from '../../constants/Channels' | ||
import Storage from '../../constants/Storage' | ||
import { ClusterModel } from '../../models/Cluster' | ||
import { LogModel } from '../../models/Log' | ||
import { scriptsPath } from './PathManager' | ||
import { execStreamScriptFile, getProcessList } from './ShellManager' | ||
|
||
export const startFileServer = async (window: BrowserWindow, cluster: ClusterModel) => { | ||
const existingServer = await getProcessList('http-server') | ||
if (existingServer.length > 0) { | ||
window.webContents.send(Channels.Utilities.Log, cluster.id, { | ||
category: 'file server', | ||
message: `File server already running. http-server count: ${existingServer.length}` | ||
} as LogModel) | ||
return | ||
} | ||
|
||
// Below block of code is to ensure file server is stopped when app is closed. | ||
app.on('before-quit', async (e) => { | ||
try { | ||
e.preventDefault() | ||
|
||
const existingServers = await getProcessList('http-server') | ||
existingServers.forEach((httpProcess) => { | ||
kill(httpProcess.pid) | ||
}) | ||
} catch {} | ||
|
||
app.quit() | ||
process.exit() | ||
}) | ||
|
||
const scriptsFolder = scriptsPath() | ||
const fileServerScript = path.join(scriptsFolder, 'configure-file-server.sh') | ||
|
||
const onFileServerStd = (data: any) => { | ||
try { | ||
window.webContents.send(Channels.Utilities.Log, cluster.id, { | ||
category: 'file server', | ||
message: data | ||
} as LogModel) | ||
} catch {} | ||
} | ||
|
||
execStreamScriptFile( | ||
fileServerScript, | ||
[`-f "${cluster.configs[Storage.ENGINE_PATH]}"`], | ||
onFileServerStd, | ||
onFileServerStd | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters