@@ -37,8 +37,6 @@ using Dates: now
3737
3838using QuartoNotebookRunner
3939using Sockets
40- using Pkg
41- using TOML
4240
4341transport_file = ARGS [1 ]
4442transport_dir = dirname (transport_file)
5048server = QuartoNotebookRunner. serve (; timeout = 300 )
5149port = server. port
5250
53- const JSONDict = Dict{String,Union{Int,String,Float64}}
54-
55- function json_string (d:: JSONDict )
56- iob = IOBuffer ()
57- print (iob, " {" )
58- for (i, (key, value)) in enumerate (d)
59- i > 1 && print (iob, " ," )
60- show (iob, key)
61- print (iob, " :" )
62- show (iob, value)
63- end
64- print (iob, " }" )
65- return String (take! (iob))
66- end
67-
68- active_project_file = Base. active_project ()
69- active_project_dir = dirname (active_project_file)
70- if active_project_dir == transport_dir
71- active_project_dir = " quarto internal"
72- end
73-
74- qnr_uuid = " 4c0109c6-14e9-4c88-93f0-2b974d3468f4"
75- active_project_file_parsed = TOML. parsefile (active_project_file)
76- # the Pkg.dependencies way doesn't work if the env is QuartoNotebookRunner itself
77- qnr_version = if get (active_project_file_parsed, " uuid" , " " ) == qnr_uuid
78- active_project_file_parsed[" version" ]:: String
79- else
80- string (Pkg. dependencies ()[Base. UUID (qnr_uuid)]. version)
81- end
82-
83- json = json_string (JSONDict ([
84- " port" => Int64 (port),
85- " pid" => Int64 (Base. Libc. getpid ()),
86- " key" => string (server. key),
87- " juliaVersion" => string (VERSION ),
88- " environment" => active_project_dir,
89- " runnerVersion" => qnr_version,
90- ]))
91-
9251open (transport_file, " w" ) do io
93- println (io, json )
52+ println (io, """ {"port": $port , "pid": $(Base . Libc . getpid ()) , "key": " $(server . key) "} """ )
9453end
9554
9655@info " Starting server at $(now ()) "
0 commit comments