mirror of
https://github.com/logos-storage/logos-storage-network-crawler.git
synced 2026-01-03 14:03:09 +00:00
applies formatting
This commit is contained in:
parent
3f12bc5d21
commit
d2eac93c0f
12
.github/workflows/main.yml
vendored
12
.github/workflows/main.yml
vendored
@ -3,6 +3,18 @@ name: CI
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
linting:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check `nph` formatting
|
||||
uses: arnetheduck/nph-action@v1
|
||||
with:
|
||||
version: 0.6.1
|
||||
options: "./"
|
||||
fail: true
|
||||
suggest: true
|
||||
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
|
||||
@ -18,6 +18,7 @@ Metrics are published from a scrape target.
|
||||
# Usage
|
||||
|
||||
```sh
|
||||
nimble format
|
||||
nimble build
|
||||
nimble test
|
||||
nimble run
|
||||
|
||||
@ -3,14 +3,15 @@ import pkg/chronos
|
||||
|
||||
import ./codexcrawler/main
|
||||
import ./codexcrawler/config
|
||||
import ./codexcrawler/metrics
|
||||
|
||||
when defined(posix):
|
||||
import system/ansi_c
|
||||
|
||||
type
|
||||
ApplicationStatus {.pure.} = enum
|
||||
Stopped,
|
||||
Stopping,
|
||||
Stopped
|
||||
Stopping
|
||||
Running
|
||||
|
||||
Application = ref object
|
||||
@ -20,8 +21,11 @@ proc run(app: Application) =
|
||||
let config = parseConfig()
|
||||
info "Loaded configuration", config
|
||||
|
||||
app.status = ApplicationStatus.Running
|
||||
setupMetrics(config.metricsAddress, config.metricsPort)
|
||||
info "Metrics endpoint initialized"
|
||||
|
||||
info "Starting application"
|
||||
app.status = ApplicationStatus.Running
|
||||
waitFor startApplication()
|
||||
|
||||
while app.status == ApplicationStatus.Running:
|
||||
@ -30,7 +34,7 @@ proc run(app: Application) =
|
||||
except Exception as exc:
|
||||
error "Unhandled exception", msg = exc.msg
|
||||
quit QuitFailure
|
||||
notice "Done"
|
||||
notice "Application closed"
|
||||
|
||||
when isMainModule:
|
||||
let app = Application()
|
||||
@ -46,7 +50,8 @@ when isMainModule:
|
||||
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
||||
try:
|
||||
setupForeignThreadGc()
|
||||
except Exception as exc: raiseAssert exc.msg
|
||||
except Exception as exc:
|
||||
raiseAssert exc.msg
|
||||
notice "Shutting down after having received SIGINT"
|
||||
onStopSignal()
|
||||
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
# Package
|
||||
|
||||
version = "0.0.1"
|
||||
author = "Codex core contributors"
|
||||
description = "Crawler for Codex networks"
|
||||
license = "MIT"
|
||||
skipDirs = @["tests"]
|
||||
bin = @["codexcrawler"]
|
||||
version = "0.0.1"
|
||||
author = "Codex core contributors"
|
||||
description = "Crawler for Codex networks"
|
||||
license = "MIT"
|
||||
skipDirs = @["tests"]
|
||||
bin = @["codexcrawler"]
|
||||
|
||||
# Dependencies
|
||||
requires "secp256k1#2acbbdcc0e63002a013fff49f015708522875832" # >= 0.5.2 & < 0.6.0
|
||||
requires "protobuf_serialization#5a31137a82c2b6a989c9ed979bb636c7a49f570e" # >= 0.2.0 & < 0.3.0
|
||||
requires "protobuf_serialization#5a31137a82c2b6a989c9ed979bb636c7a49f570e"
|
||||
# >= 0.2.0 & < 0.3.0
|
||||
requires "nimcrypto >= 0.5.4"
|
||||
requires "bearssl == 0.2.5"
|
||||
requires "chronicles >= 0.10.2 & < 0.11.0"
|
||||
@ -20,8 +21,13 @@ requires "stew >= 0.2.0"
|
||||
requires "stint#3236fa68394f1e3a06e2bc34218aacdd2d675923"
|
||||
requires "https://github.com/codex-storage/nim-datastore >= 0.1.0 & < 0.2.0"
|
||||
requires "questionable >= 0.10.15 & < 0.11.0"
|
||||
requires "https://github.com/codex-storage/nim-codex-dht#4bd3a39e0030f8ee269ef217344b6b59ec2be6dc" # 7 Jan 2024 - Support for Nim 2.0.14
|
||||
requires "https://github.com/codex-storage/nim-codex-dht#4bd3a39e0030f8ee269ef217344b6b59ec2be6dc"
|
||||
# 7 Jan 2024 - Support for Nim 2.0.14
|
||||
requires "docopt >= 0.7.1 & < 1.0.0"
|
||||
requires "nph >= 0.6.1 & < 1.0.0"
|
||||
|
||||
task format, "Formatting...":
|
||||
exec "nph ./"
|
||||
|
||||
task test, "Run tests":
|
||||
exec "nimble install -d -y"
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import std/net
|
||||
import ./version
|
||||
|
||||
let doc = """
|
||||
let doc =
|
||||
"""
|
||||
Codex Network Crawler. Generates network metrics.
|
||||
|
||||
Usage:
|
||||
@ -18,21 +19,17 @@ Options:
|
||||
import strutils
|
||||
import docopt
|
||||
|
||||
type
|
||||
CrawlerConfig* = ref object
|
||||
logLevel*: string
|
||||
metricsAddress*: IpAddress
|
||||
metricsPort*: Port
|
||||
dataDir*: string
|
||||
discPort*: Port
|
||||
type CrawlerConfig* = ref object
|
||||
logLevel*: string
|
||||
metricsAddress*: IpAddress
|
||||
metricsPort*: Port
|
||||
dataDir*: string
|
||||
discPort*: Port
|
||||
|
||||
proc `$`*(config: CrawlerConfig): string =
|
||||
"CrawlerConfig:" &
|
||||
" logLevel=" & config.logLevel &
|
||||
" metricsAddress=" & $config.metricsAddress &
|
||||
" metricsPort=" & $config.metricsPort &
|
||||
" dataDir=" & config.dataDir &
|
||||
" discPort=" & $config.discPort
|
||||
"CrawlerConfig:" & " logLevel=" & config.logLevel & " metricsAddress=" &
|
||||
$config.metricsAddress & " metricsPort=" & $config.metricsPort & " dataDir=" &
|
||||
config.dataDir & " discPort=" & $config.discPort
|
||||
|
||||
proc parseConfig*(): CrawlerConfig =
|
||||
let args = docopt(doc, version = crawlerFullVersion)
|
||||
|
||||
@ -11,8 +11,7 @@ proc startApplication*() {.async.} =
|
||||
await sleepAsync(1000)
|
||||
|
||||
asyncSpawn aaa()
|
||||
|
||||
|
||||
await sleepAsync(1000)
|
||||
|
||||
notice "b"
|
||||
|
||||
|
||||
@ -20,5 +20,5 @@ const
|
||||
nimBanner* = getNimBanner()
|
||||
|
||||
crawlerFullVersion* =
|
||||
"CodexNetworkCrawler version: " & crawlerVersion & "\p" & "CodexNetworkCrawler revision: " & crawlerRevision & "\p" &
|
||||
nimBanner
|
||||
"CodexNetworkCrawler version: " & crawlerVersion & "\p" &
|
||||
"CodexNetworkCrawler revision: " & crawlerRevision & "\p" & nimBanner
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
# Package
|
||||
|
||||
version = "0.0.1"
|
||||
author = "Codex core contributors"
|
||||
description = "Tests for crawler for Codex networks"
|
||||
license = "MIT"
|
||||
installFiles = @["build.nims"]
|
||||
version = "0.0.1"
|
||||
author = "Codex core contributors"
|
||||
description = "Tests for crawler for Codex networks"
|
||||
license = "MIT"
|
||||
installFiles = @["build.nims"]
|
||||
|
||||
# Dependencies
|
||||
requires "asynctest >= 0.5.2 & < 0.6.0"
|
||||
requires "asynctest >= 0.5.2 & < 0.6.0"
|
||||
requires "unittest2 <= 0.3.0"
|
||||
|
||||
task test, "Run tests":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user