mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Close proxy server on app quit
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
65900e728d
commit
3999e9909a
@ -26,6 +26,7 @@ const promiseIpc = new PromiseIpc({ timeout: 2000 })
|
||||
|
||||
let windowManager: WindowManager = null;
|
||||
let clusterManager: ClusterManager = null;
|
||||
let proxyServer: proxy.LensProxy = null;
|
||||
const vmURL = (isDevelopment) ? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}` : formatUrl({
|
||||
pathname: path.join(__dirname, "index.html"),
|
||||
protocol: "file",
|
||||
@ -57,10 +58,9 @@ async function main() {
|
||||
|
||||
// create cluster manager
|
||||
clusterManager = new ClusterManager(clusterStore.getAllClusterObjects(), port)
|
||||
|
||||
// run proxy
|
||||
try {
|
||||
proxy.listen(port, clusterManager)
|
||||
proxyServer = proxy.listen(port, clusterManager)
|
||||
} catch (error) {
|
||||
logger.error(`Could not start proxy (127.0.0:${port}): ${error.message}`)
|
||||
await dialog.showErrorBox("Lens Error", `Could not start proxy (127.0.0:${port}): ${error.message || "unknown error"}`)
|
||||
@ -123,5 +123,6 @@ app.on("activate", () => {
|
||||
app.on("will-quit", async (event) => {
|
||||
event.preventDefault(); // To allow mixpanel sending to be executed
|
||||
if (clusterManager) clusterManager.stop()
|
||||
if (proxyServer) proxyServer.close()
|
||||
app.exit(0);
|
||||
})
|
||||
|
||||
@ -17,6 +17,7 @@ export class LensProxy {
|
||||
protected clusterManager: ClusterManager
|
||||
protected retryCounters: Map<string, number> = new Map()
|
||||
protected router: Router
|
||||
protected proxyServer: http.Server
|
||||
|
||||
constructor(port: number, clusterManager: ClusterManager) {
|
||||
this.port = port
|
||||
@ -27,6 +28,12 @@ export class LensProxy {
|
||||
public run() {
|
||||
const proxyServer = this.buildProxyServer();
|
||||
proxyServer.listen(this.port, "127.0.0.1")
|
||||
this.proxyServer = proxyServer
|
||||
}
|
||||
|
||||
public close() {
|
||||
logger.info("Closing proxy server")
|
||||
this.proxyServer.close()
|
||||
}
|
||||
|
||||
protected buildProxyServer() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user