2022-05-12 11:42:18 +00:00
|
|
|
import std/osproc
|
|
|
|
import std/os
|
|
|
|
import std/streams
|
|
|
|
import std/strutils
|
|
|
|
|
|
|
|
const workingDir = currentSourcePath() / ".." / ".." / ".."
|
|
|
|
const executable = "build" / "dagger"
|
|
|
|
|
|
|
|
proc startNode*(args: openArray[string], debug = false): Process =
|
|
|
|
if debug:
|
|
|
|
result = startProcess(executable, workingDir, args, options={poParentStreams})
|
|
|
|
sleep(1000)
|
|
|
|
else:
|
|
|
|
result = startProcess(executable, workingDir, args)
|
|
|
|
for line in result.outputStream.lines:
|
|
|
|
if line.contains("Started dagger node"):
|
|
|
|
break
|
|
|
|
|
|
|
|
proc stop*(node: Process) =
|
|
|
|
node.terminate()
|
2022-05-18 08:14:57 +00:00
|
|
|
discard node.waitForExit(timeout=5_000)
|
2022-05-12 11:42:18 +00:00
|
|
|
node.close()
|