mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-16 13:21:04 +01:00
shared process - clean up some types and imports
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { serve, Server, connect } from 'vs/base/parts/ipc/node/ipc.net';
|
||||
import { unlinkSync } from 'fs';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { IChannel, IServerChannel, StaticRouter, createChannelSender, createChannelReceiver } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { serve as nodeIPCServe, Server as NodeIPCServer, connect as nodeIPCConnect } from 'vs/base/parts/ipc/node/ipc.net';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
@@ -35,7 +36,6 @@ import { ILocalizationsService } from 'vs/platform/localizations/common/localiza
|
||||
import { combinedDisposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { DownloadService } from 'vs/platform/download/common/downloadService';
|
||||
import { IDownloadService } from 'vs/platform/download/common/download';
|
||||
import { IChannel, IServerChannel, StaticRouter, createChannelSender, createChannelReceiver } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { NodeCachedDataCleaner } from 'vs/code/electron-browser/sharedProcess/contrib/nodeCachedDataCleaner';
|
||||
import { LanguagePackCachedDataCleaner } from 'vs/code/electron-browser/sharedProcess/contrib/languagePackCachedDataCleaner';
|
||||
import { StorageDataCleaner } from 'vs/code/electron-browser/sharedProcess/contrib/storageDataCleaner';
|
||||
@@ -95,7 +95,7 @@ const eventPrefix = 'monacoworkbench';
|
||||
class MainProcessService implements IMainProcessService {
|
||||
|
||||
constructor(
|
||||
private server: Server,
|
||||
private server: NodeIPCServer,
|
||||
private mainRouter: StaticRouter
|
||||
) { }
|
||||
|
||||
@@ -110,7 +110,7 @@ class MainProcessService implements IMainProcessService {
|
||||
}
|
||||
}
|
||||
|
||||
async function main(server: Server, initData: ISharedProcessInitData, configuration: ISharedProcessConfiguration): Promise<void> {
|
||||
async function main(server: NodeIPCServer, initData: ISharedProcessInitData, configuration: ISharedProcessConfiguration): Promise<void> {
|
||||
const services = new ServiceCollection();
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
@@ -276,16 +276,16 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
|
||||
});
|
||||
}
|
||||
|
||||
function setupIPC(hook: string): Promise<Server> {
|
||||
function setup(retry: boolean): Promise<Server> {
|
||||
return serve(hook).then(null, err => {
|
||||
if (!retry || platform.isWindows || err.code !== 'EADDRINUSE') {
|
||||
function setupIPC(hook: string): Promise<NodeIPCServer> {
|
||||
function setup(retry: boolean): Promise<NodeIPCServer> {
|
||||
return nodeIPCServe(hook).then(null, err => {
|
||||
if (!retry || isWindows || err.code !== 'EADDRINUSE') {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
|
||||
// should retry, not windows and eaddrinuse
|
||||
|
||||
return connect(hook, '').then(
|
||||
return nodeIPCConnect(hook, '').then(
|
||||
client => {
|
||||
// we could connect to a running instance. this is not good, abort
|
||||
client.dispose();
|
||||
@@ -296,7 +296,7 @@ function setupIPC(hook: string): Promise<Server> {
|
||||
// let's delete it, since we can't connect to it
|
||||
// and the retry the whole thing
|
||||
try {
|
||||
fs.unlinkSync(hook);
|
||||
unlinkSync(hook);
|
||||
} catch (e) {
|
||||
return Promise.reject(new Error('Error deleting the shared ipc hook.'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user