2023-05-06 19:08:38 +00:00
|
|
|
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
2022-06-09 05:28:26 +00:00
|
|
|
# SPDX-License-Identifier: Unlicense
|
|
|
|
|
2023-05-18 11:41:37 +00:00
|
|
|
import std/[json, os, osproc]
|
2023-10-05 17:05:06 +00:00
|
|
|
import preserves
|
|
|
|
import syndicate, syndicate/relays
|
2022-06-09 05:28:26 +00:00
|
|
|
|
|
|
|
from preserves/jsonhooks import toPreserveHook
|
|
|
|
|
2023-07-26 10:45:41 +00:00
|
|
|
import ./schema/config, ./json_messages
|
2023-05-05 16:38:04 +00:00
|
|
|
|
2022-06-09 05:28:26 +00:00
|
|
|
proc runChild: string =
|
|
|
|
let params = commandLineParams()
|
|
|
|
if params.len < 1:
|
|
|
|
stderr.writeLine "not enough parameters"
|
|
|
|
quit 1
|
|
|
|
let
|
|
|
|
cmd = params[0]
|
|
|
|
args = params[1..params.high]
|
|
|
|
try: result = execProcess(command=cmd, args=args, options={poUsePath})
|
2023-07-26 08:45:58 +00:00
|
|
|
except CatchableError as err:
|
2023-07-26 10:45:41 +00:00
|
|
|
quit("execProcess failed: " & err.msg)
|
2022-06-09 05:28:26 +00:00
|
|
|
if result == "":
|
|
|
|
stderr.writeLine "no ouput"
|
|
|
|
quit 1
|
|
|
|
|
2023-09-05 10:37:17 +00:00
|
|
|
runActor("main") do (ds: Cap; turn: var Turn):
|
|
|
|
connectStdio(ds, turn)
|
|
|
|
let js = runChild().parseJson()
|
|
|
|
message(turn, ds, RecvJson(data: js))
|
|
|
|
discard publish(turn, ds, RecvJson(data: js))
|