This repository has been archived by the owner on Dec 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathload.jl
50 lines (40 loc) · 1.68 KB
/
load.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
for fn in [
"utils.jl",
"nostr.jl",
"bech32.jl",
"clocks.jl",
"perf_stats.jl",
"fetching.jl",
"db.jl",
"metrics_logger.jl",
"app.jl",
"perf_test_redirection.jl",
"cache_server_handlers.jl",
"cache_server.jl",
]
fn = "src/$fn"
println(fn, " -> ", include(fn))
end
STORAGEPATH = get(ENV, "PRIMALSERVER_STORAGE_PATH", "$(pwd())/var")
PROXY = get(ENV, "PRIMALSERVER_PROXY", nothing)
FETCHER_SINCE = try parse(Int, ENV["PRIMALSERVER_FETCHER_SINCE"]) catch _ trunc(Int, time()) end
NODEIDX = parse(Int, get(ENV, "PRIMALSERVER_NODE_IDX", "1"))
RELAYS_FILE = get(ENV, "PRIMALSERVER_RELAYS", nothing)
#DB.PRINT_EXCEPTIONS[] = true
gctask = Utils.GCTask(; full=true, period=300)
auto_fetch_missing_events = get(ENV, "PRIMALSERVER_AUTO_FETCH_MISSING_EVENTS", nothing) == "1"
cache_storage = DB.CacheStorage(;
directory="$(STORAGEPATH)/primalnode$(NODEIDX)/cache",
dbargs=(; ndbs=1, journal_mode="WAL"),
auto_fetch_missing_events)
Fetching.message_processors[:cache_storage] = (msg)->DB.import_msg_into_storage(msg, cache_storage)
Fetching.EVENTS_DATA_DIR[] = "$(STORAGEPATH)/primalnode$(NODEIDX)/fetcher"
Fetching.PROXY_URI[] = PROXY
if isnothing(RELAYS_FILE)
Fetching.load_relays()
else
union!(Fetching.relays, [r for r in readlines(RELAYS_FILE) if !isempty(r)])
end
CacheServer.HOST[] = get(ENV, "PRIMALSERVER_HOST", "0.0.0.0")
CacheServer.PORT[] = 8800+NODEIDX
cache_storage.event_processors[:broadcast_event] = CacheServerHandlers.broadcast