Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
add option to start DCD quiet
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Nov 9, 2018
1 parent 6dde5e4 commit 15652c4
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions source/workspaced/com/dcd.d
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ class DCDComponent : ComponentWrapper
}

/// This will start the dcd-server and load import paths from the current provider
void setupServer(string[] additionalImports = [])
void setupServer(string[] additionalImports = [], bool quietServer = false)
{
startServer(importPaths ~ importFiles ~ additionalImports);
startServer(importPaths ~ importFiles ~ additionalImports, quietServer);
}

/// This will start the dcd-server
void startServer(string[] additionalImports = [])
void startServer(string[] additionalImports = [], bool quietServer = false)
{
if (isPortRunning(port))
throw new Exception("Already running dcd on port " ~ port.to!string);
Expand All @@ -118,23 +118,32 @@ class DCDComponent : ComponentWrapper
if (i.length)
imports ~= "-I" ~ i;
this.runningPort = port;
this.socketFile = buildPath(tempDir, "workspace-d-sock" ~ thisProcessID.to!string ~ "-" ~ uniform!ulong.to!string(36));
this.socketFile = buildPath(tempDir,
"workspace-d-sock" ~ thisProcessID.to!string ~ "-" ~ uniform!ulong.to!string(36));
serverPipes = raw([serverPath] ~ clientArgs ~ imports,
Redirect.stdin | Redirect.stderr | Redirect.stdoutToStderr);
while (!serverPipes.stderr.eof)
{
string line = serverPipes.stderr.readln();
stderr.writeln("Server: ", line);
stderr.flush();
if (!quietServer)
{
stderr.writeln("Server: ", line);
stderr.flush();
}
if (line.canFind("Startup completed in "))
break;
}
running = true;
new Thread({
while (!serverPipes.stderr.eof)
{
stderr.writeln("Server: ", serverPipes.stderr.readln());
}
if (quietServer)
foreach (block; serverPipes.stderr.byChunk(4096))
{
}
else
while (!serverPipes.stderr.eof)
{
stderr.writeln("Server: ", serverPipes.stderr.readln());
}
auto code = serverPipes.pid.wait();
stderr.writeln("DCD-Server stopped with code ", code);
if (code != 0)
Expand Down Expand Up @@ -193,14 +202,14 @@ class DCDComponent : ComponentWrapper

/// This will stop the dcd-server safely and restart it again using setup-server asynchronously
/// Returns: null
Future!void restartServer()
Future!void restartServer(bool quiet = false)
{
auto ret = new Future!void;
new Thread({ /**/
try
{
stopServerSync();
setupServer();
setupServer([], quiet);
ret.finish();
}
catch (Throwable t)
Expand Down

0 comments on commit 15652c4

Please sign in to comment.