Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow worker to work when a host has multiple IP addresses #1879

Merged
merged 1 commit into from
Jan 3, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function process_options(args::Array{Any,1})
if args[i]=="-q" || args[i]=="--quiet"
quiet = true
elseif args[i]=="--worker"
start_worker()
start_worker(args[i+1])
# doesn't return
elseif args[i]=="-e"
# TODO: support long options
Expand Down
15 changes: 8 additions & 7 deletions base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -876,17 +876,18 @@ end

# the entry point for julia worker processes. does not return.
# argument is descriptor to write listening port # to.
start_worker() = start_worker(1)
function start_worker(wrfd)
start_worker(mode :: String) = start_worker(mode, 1)
function start_worker(mode :: String, wrfd)
port = [int16(9009)]
sockfd = ccall(:open_any_tcp_port, Int32, (Ptr{Int16},), port)
if sockfd == -1
error("could not bind socket")
end
io = fdio(wrfd)
host = mode == "local" ? "localhost" : getipaddr()
write(io, "julia_worker:") # print header
write(io, "$(dec(port[1]))#") # print port
write(io, getipaddr()) # print hostname
write(io, host) # print hostname
write(io, '\n')
flush(io)
# close stdin; workers will not use it
Expand Down Expand Up @@ -974,11 +975,11 @@ function ssh_tunnel(user, host, port)
end

function worker_ssh_cmd(host)
`ssh -n $host "bash -l -c \"cd $JULIA_HOME && ./julia-release-basic --worker\""`
`ssh -n $host "bash -l -c \"cd $JULIA_HOME && ./julia-release-basic --worker remote\""`
end

#function worker_ssh_cmd(host, key)
# `ssh -i $key -n $host "bash -l -c \"cd $JULIA_HOME && ./julia-release-basic --worker\""`
# `ssh -i $key -n $host "bash -l -c \"cd $JULIA_HOME && ./julia-release-basic --worker remote\""`
#end

function addprocs_ssh(machines)
Expand All @@ -1003,7 +1004,7 @@ end
# add_workers(PGRP, start_remote_workers(machines, map(x->worker_ssh_cmd(x[1],x[2]), cmdargs)))
#end

worker_local_cmd() = `$JULIA_HOME/julia-release-basic --worker`
worker_local_cmd() = `$JULIA_HOME/julia-release-basic --worker local`

addprocs_local(np::Integer) =
add_workers(PGRP, start_remote_workers({ "localhost" for i=1:np },
Expand All @@ -1015,7 +1016,7 @@ function start_sge_workers(n)
sgedir = "$home/../../SGE"
run(`mkdir -p $sgedir`)
qsub_cmd = `qsub -N JULIA -terse -e $sgedir -o $sgedir -t 1:$n`
`echo $home/julia-release-basic --worker` | qsub_cmd
`echo $home/julia-release-basic --worker remote` | qsub_cmd
out = cmd_stdout_stream(qsub_cmd)
if !success(qsub_cmd)
error("batch queue not available (could not run qsub)")
Expand Down