-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add startup callback to settings (#89)
* add startup callback to settings * nimble -y test * cancel threads * fix * change addExitProc condition,thread core and sys exported from nim v2 * so pthread_cancel platform specific --------- Co-authored-by: bung87 <[email protected]>
- Loading branch information
1 parent
0f7b07f
commit 17e322b
Showing
5 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,5 +26,5 @@ jobs: | |
nimversion: ${{ matrix.nimversion }} | ||
- name: Test | ||
run: | | ||
nimble test | ||
nimble -y test | ||
nimble refresh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
/tests/* | ||
!/tests/*.nim | ||
!/tests/*.cfg | ||
* | ||
!**/ | ||
!*.* | ||
*.out | ||
.DS_Store | ||
!.gitattributes | ||
!.gitignore | ||
!readme.md | ||
!.gitkeep | ||
!*.nim | ||
!*.nims | ||
!*.nimble | ||
!*.h | ||
!*.css | ||
!*.html | ||
*.exe | ||
!*/ | ||
nimbledeps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
charset = "utf-8" | ||
[Package] | ||
name = "hello" | ||
--threads:on | ||
[Author] | ||
name = "nim-lang" | ||
website = "nim-lang.org" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os, options, asyncdispatch, parsecfg, strutils, streams | ||
import httpbeast | ||
|
||
const CurDir = currentSourcePath.parentDir | ||
|
||
var threadsOn {.threadvar.}: bool | ||
var name {.threadvar.}: string | ||
|
||
proc onRequest(req: Request): Future[void] = | ||
if req.httpMethod == some(HttpGet): | ||
case req.path.get() | ||
of "/": | ||
req.send("name:$#,threads:$#." % [name, $threadsOn]) | ||
else: | ||
req.send(Http404) | ||
|
||
var startup = proc () = | ||
let configFile = CurDir / "startup.ini" | ||
var f = newFileStream(configFile, fmRead) | ||
assert f != nil, "cannot open " & configFile | ||
var p: CfgParser | ||
var section: string | ||
open(p, f, configFile) | ||
while true: | ||
var e = next(p) | ||
case e.kind | ||
of cfgEof: break | ||
of cfgSectionStart: ## a `[section]` has been parsed | ||
section = e.section | ||
of cfgKeyValuePair: | ||
if section == "Package" and e.key == "name": | ||
name = e.value | ||
of cfgOption: | ||
if e.key == "threads": | ||
if e.value == "on": | ||
threadsOn = true | ||
of cfgError: | ||
echo e.msg | ||
close(p) | ||
|
||
run(onRequest, initSettings(startup = startup)) |