Skip to content

Commit

Permalink
Merge pull request #2094 from swadey/master
Browse files Browse the repository at this point in the history
general --bind-to solution for vpn/multi-IP systems
  • Loading branch information
vtjnash committed Jan 21, 2013
2 parents 68b547e + 3997e90 commit 8261a29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function try_include(f::String)
end

function process_options(args::Array{Any,1})
global ARGS
global ARGS, bind_addr
quiet = false
repl = true
startup = true
Expand All @@ -188,6 +188,9 @@ function process_options(args::Array{Any,1})
elseif args[i]=="--worker"
start_worker()
# doesn't return
elseif args[i]=="--bind-to"
i += 1
bind_addr = args[i]
elseif args[i]=="-e"
# TODO: support long options
repl = false
Expand Down Expand Up @@ -270,6 +273,9 @@ isinteractive() = (is_interactive::Bool)
function _start()
# set up standard streams

# set default local address
global bind_addr = getipaddr()

@windows_only if !has(ENV,"HOME")
ENV["HOME"] = joinpath(ENV["APPDATA"],"julia")
end
Expand Down
10 changes: 5 additions & 5 deletions base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ function start_worker(out::Stream)
(actual_port,sock) = open_any_tcp_port(default_port,(handle,status)->accept_handler(handle,status))
write(out, "julia_worker:") # print header
write(out, "$(dec(actual_port))#") # print port
write(out, "localhost") #TODO: print hostname
write(out, bind_addr) #TODO: print hostname
write(out, '\n')
# close STDIN; workers will not use it
#close(STDIN)
Expand Down Expand Up @@ -974,11 +974,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 remote\""`
`ssh -n $host "bash -l -c \"cd $JULIA_HOME && ./julia-release-basic --worker\""`
end

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

function addprocs_ssh(machines)
Expand All @@ -1003,7 +1003,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 local`
worker_local_cmd() = `$JULIA_HOME/julia-release-basic --bind-to $bind_addr --worker`

addprocs_local(np::Integer) =
add_workers(PGRP, start_remote_workers({ "localhost" for i=1:np },
Expand All @@ -1015,7 +1015,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 remote` | qsub_cmd
`echo $home/julia-release-basic --worker` | qsub_cmd
out = cmd_stdout_stream(qsub_cmd)
if !success(qsub_cmd)
error("batch queue not available (could not run qsub)")
Expand Down

0 comments on commit 8261a29

Please sign in to comment.