Add debug switch and API endpoint to stop server when in debug mode.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import asyncdispatch, bcrypt, jester, json, jwt, osproc, sequtils, tempfile,
|
||||
import asyncdispatch, bcrypt, jester, json, jwt, os, osproc, sequtils, tempfile,
|
||||
times, unittest
|
||||
|
||||
import ./configuration, ./core, private/util
|
||||
@ -111,6 +111,7 @@ template requireAuth() =
|
||||
|
||||
proc start*(givenCfg: StrawBossConfig): void =
|
||||
|
||||
let stopFuture = newFuture[void]()
|
||||
var workers: seq[Worker] = @[]
|
||||
|
||||
routes:
|
||||
@ -136,4 +137,10 @@ proc start*(givenCfg: StrawBossConfig): void =
|
||||
buildRef: if @"buildRef" != "": @"buildRef" else: nil,
|
||||
forceRebuild: false))) # TODO support this with optional query params
|
||||
|
||||
runForever()
|
||||
post "/service/debug/stop":
|
||||
if not givenCfg.debug: resp(Http404, makeJsonResp(Http404), "application/json")
|
||||
else:
|
||||
callSoon(proc(): void = complete(stopFuture))
|
||||
resp($(%*"shutting down"), "application/json")
|
||||
|
||||
waitFor(stopFuture)
|
||||
|
Reference in New Issue
Block a user