Skip to content

Commit

Permalink
コンテナ指定にIDを使うように修正 #166 (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiro4989 authored Jun 12, 2020
1 parent c9d434e commit 0f8afe7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions websh_server/src/dockerclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,27 @@ proc runContainer*(self: DockerClient, name: string, image: string, cmds: seq[st
resp = self.createContainer(name = name, image = image, cmds = cmds, script = script, mediaDir = mediaDir, imageDir = imageDir)
if not resp.code.is2xx:
return ("", "", statusSystemError, &"failed to call 'createContainer': cmds={cmds} resp.body={resp.body}")
let id = resp.body.parseJson["Id"].getStr

resp = self.startContainer(name = name)
resp = self.startContainer(name = id)
if not resp.code.is2xx:
return ("", "", statusSystemError, &"failed to call 'startContainer': cmds={cmds} resp.body={resp.body}")

self.waitFinish(name = name)
self.waitFinish(name = id)

var stdoutStr: string
resp = self.getStdoutLog(name = name)
resp = self.getStdoutLog(name = id)
if not resp.code.is2xx:
return ("", "", statusSystemError, &"failed to call 'getStdoutLog': cmds={cmds} resp.body={resp.body}")
stdoutStr = resp.body.parseLog

var stderrStr: string
resp = self.getStderrLog(name = name)
resp = self.getStderrLog(name = id)
if not resp.code.is2xx:
return ("", "", statusSystemError, &"failed to call 'getStderrLog': cmds={cmds} resp.body={resp.body}")
stderrStr = resp.body.parseLog

discard self.killContainer(name = name)
discard self.removeContainer(name = name)
discard self.killContainer(name = id)
discard self.removeContainer(name = id)

return (stdoutStr, stderrStr, statusOk, "")

0 comments on commit 0f8afe7

Please sign in to comment.