Skip to content

Commit 60fbf0f

Browse files
authored
Merge pull request #451 from JuliaParallel/jps/webdash-fix-host
DaggerWebDash: Use gethostname and getipaddr
2 parents 6c91727 + ad5a95c commit 60fbf0f

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

Diff for: lib/DaggerWebDash/Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DaggerWebDash"
22
uuid = "cfc5aa84-1a2a-41ab-b391-ede92ecae40c"
33
authors = ["Julian P Samaroo <[email protected]>"]
4-
version = "0.1.2"
4+
version = "0.1.3"
55

66
[deps]
77
Dagger = "d58978e5-989f-55fb-8d15-ea34adc7bf54"

Diff for: lib/DaggerWebDash/assets/d3.v7.min.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: lib/DaggerWebDash/src/d3.jl

+17-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const D3R_ACTUAL_PORT = Dict{Int,Int}()
5757
# TODO: Concrete socket types
5858
const D3R_CLIENT_SOCKETS = Dict{Int,Dict{Int,Vector{Any}}}()
5959

60-
const D3R_WORKER_HOST_MAP = Dict{Int,IPAddr}()
60+
const D3R_WORKER_HOST_MAP = Dict{Int,Union{IPAddr,String}}()
6161
const D3R_WORKER_PORT_MAP = Dict{Int,Int}()
6262

6363
struct D3Renderer
@@ -143,6 +143,17 @@ function d3r_init(port::Int, port_range::UnitRange, config_updated::Ref{Bool}, c
143143
Dict(:status=>404)
144144
end
145145
end),
146+
page("/assets/:path", req->begin
147+
path = req[:params][:path]
148+
occursin("..", path) && return Dict(:status=>404)
149+
assets_path = normpath(joinpath(@__DIR__, "..", "assets"))
150+
path = normpath(joinpath(assets_path, path))
151+
if ispath(path) && normpath(dirname(path)) == assets_path
152+
Dict(:body=>String(read(path)))
153+
else
154+
Dict(:status=>404)
155+
end
156+
end),
146157
page("/worker_id", respond("$(myid())")),
147158
page("/worker/:id/:location", req->begin
148159
id = parse(Int, req[:params][:id])
@@ -311,7 +322,11 @@ end
311322
function worker_host_port(id::Int, port::Int, port_range::UnitRange)
312323
worker_host = get!(D3R_WORKER_HOST_MAP, port) do
313324
worker_host, worker_port = remotecall_fetch(id, port) do port
314-
(MemPool.host, get_actual_port(port, port_range))
325+
host = gethostname()
326+
if isempty(host)
327+
host = getipaddr()
328+
end
329+
(host, get_actual_port(port, port_range))
315330
end
316331
D3R_WORKER_PORT_MAP[port] = worker_port
317332
worker_host

Diff for: lib/DaggerWebDash/src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>Dagger Dashboard</title>
6-
<script type="text/javascript" src="https://d3js.org/d3.v7.min.js"></script>
6+
<script type="text/javascript" src="/assets/d3.v7.min.js"></script>
77
</head>
88
<body>
99
<div style="border: 2px solid black">

0 commit comments

Comments
 (0)