Skip to content

Commit

Permalink
Merge pull request #4612 from JoeRobich/fix-multi-start
Browse files Browse the repository at this point in the history
Ensure we only start one instance of OmniSharp server
  • Loading branch information
JoeRobich committed Jun 14, 2021
2 parents 19b027b + b5b9ce7 commit 3534e25
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/omnisharp/server.ts
Expand Up @@ -250,6 +250,10 @@ export class OmniSharpServer {
// --- start, stop, and connect

private async _start(launchTarget: LaunchTarget, options: Options): Promise<void> {
if (this._state != ServerState.Stopped) {
this.eventStream.post(new ObservableEvents.OmnisharpServerOnServerError("Attempt to start OmniSharp server failed because another server instance is running."));
return;
}

if (launchTarget.kind === LaunchTargetKind.LiveShare) {
this.eventStream.post(new ObservableEvents.OmnisharpServerMessage("During Live Share sessions language services are provided by the Live Share server."));
Expand Down Expand Up @@ -498,6 +502,11 @@ export class OmniSharpServer {
}

public async restart(launchTarget: LaunchTarget = this._launchTarget): Promise<void> {
if (this._state == ServerState.Starting) {
this.eventStream.post(new ObservableEvents.OmnisharpServerOnServerError("Attempt to restart OmniSharp server failed because another server instance is starting."));
return;
}

if (launchTarget) {
await this.stop();
this.eventStream.post(new ObservableEvents.OmnisharpRestart());
Expand Down

0 comments on commit 3534e25

Please sign in to comment.