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

Native remote connection support #531

Merged
merged 28 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d8d25ad
almost there
pfitzseb Nov 22, 2018
a805936
add config for remote stuff
pfitzseb Nov 22, 2018
dadef3f
add command to open remote terminal
pfitzseb Nov 22, 2018
1121e0a
misc improvements
pfitzseb Nov 22, 2018
717f0a7
consume remote server config
pfitzseb Nov 23, 2018
c64d9d2
update to new api
pfitzseb Nov 23, 2018
2702e97
remove old config options
pfitzseb Nov 23, 2018
e498bf6
more guidance
pfitzseb Nov 23, 2018
8a48996
cache server config
pfitzseb Nov 23, 2018
238f478
more robustness
pfitzseb Nov 25, 2018
3033866
start of per-server exec config
pfitzseb Nov 26, 2018
2c925b1
start up in correct dir
pfitzseb Nov 27, 2018
1bf6206
better remote startup
pfitzseb Nov 27, 2018
ce0f55a
support persistent tmux sessions
pfitzseb Nov 27, 2018
70f51d8
add 'disconnect julia' command
pfitzseb Nov 27, 2018
5b0cbba
add agent forwarding
pfitzseb Nov 28, 2018
c8b7a1a
fix most path issues
pfitzseb Nov 28, 2018
31702a9
use correct path when on windows
pfitzseb Nov 28, 2018
d655796
fix init, customize tmux session name
pfitzseb Nov 28, 2018
c81d820
switch term to normal buffer on exit
pfitzseb Nov 28, 2018
d969e51
cleanup and add 'start remote julia' cmd
pfitzseb Nov 29, 2018
c9bb612
use all startup args
pfitzseb Nov 29, 2018
843760b
fix missing space
pfitzseb Nov 29, 2018
0c824a5
boot mode fix
pfitzseb Nov 29, 2018
11d489a
misc fixes
pfitzseb Nov 30, 2018
65d8934
toolbar icon
pfitzseb Nov 30, 2018
ec2ecef
dispatch to the correct element
pfitzseb Nov 30, 2018
480ff68
fix provider versions
pfitzseb Dec 3, 2018
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
20 changes: 18 additions & 2 deletions lib/connection.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,33 @@ module.exports =

consumeInk: (ink) ->
@IPC.consumeInk ink
@ink = ink

consumeTerminal: (term) ->
@terminal.consumeTerminal term

boot: ->
consumeGetServerConfig: (getconf) ->
@local.consumeGetServerConfig(getconf)

consumeGetServerName: (name) ->
@local.consumeGetServerName(name)

_boot: (provider) ->
if not @client.isActive() and not @booting
@booting = true
p = @local.start()
p = @local.start(provider)
@client.setBootMode(provider)
if @ink?
@ink.Opener.allowRemoteFiles(provider == 'Remote')
p.then =>
@booting = false
p.catch =>
@booting = false
time "Julia Boot", @client.import('ping')().then =>
metrics()

bootRemote: ->
@_boot('Remote')

boot: ->
@_boot(atom.config.get('julia-client.juliaOptions.bootMode'))
29 changes: 27 additions & 2 deletions lib/connection/client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ module.exports =

@emitter = new Emitter

@bootMode = atom.config.get('julia-client.juliaOptions.bootMode')

@ipc.writeMsg = (msg) =>
if @isActive() and @conn.ready?() isnt false
@conn.message msg
Expand Down Expand Up @@ -55,6 +57,25 @@ module.exports =
@onDetached =>
plotpane?.dispose()

@onBoot (proc) =>
@remoteConfig = proc.config

setBootMode: (@bootMode) ->

editorPath: (ed) ->
if not ed? then return ed
if @bootMode is 'Remote' and @remoteConfig?
path = ed.getPath()
if not path? then return path
ind = path.indexOf(@remoteConfig.host)
if ind > -1
path = path.slice(ind + @remoteConfig.host.length, path.length)
path = path.replace(/\\/g, '/')
return path
else
return path
else
return ed.getPath()

deactivate: ->
@emitter.dispose()
Expand Down Expand Up @@ -126,6 +147,10 @@ module.exports =
else if atom.config.get('julia-client.consoleOptions.consoleStyle') is 'REPL-based'
@clientCall 'interrupts', 'interruptREPL'

disconnect: ->
if @isActive()
@clientCall 'disconnecting', 'disconnect'

kill: ->
if @isActive()
if not @isWorking()
Expand All @@ -150,15 +175,15 @@ module.exports =
connectedError: (action = 'do that') ->
if @isActive()
atom.notifications.addError "Can't #{action} with a Julia client running.",
detail: "Stop the current client with Packages → Julia → Stop Julia."
description: "Stop the current client with Packages → Julia → Stop Julia."
true
else
false

notConnectedError: (action = 'do that') ->
if not @isActive()
atom.notifications.addError "Can't #{action} without a Julia client running.",
detail: "Start Julia using Packages → Julia → Start Julia."
description: "Start Julia using Packages → Julia → Start Julia."
true
else
false
Expand Down
36 changes: 26 additions & 10 deletions lib/connection/local.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,32 @@ cd = client.import 'cd', false

# legacy
basic = require './process/basic'

cycler = require './process/cycler'
ssh = require './process/remote'
# server = require './process/server'

# new console
basic2 = require './process/basic2'

module.exports =
# server: server
consumeGetServerConfig: (getconf) ->
ssh.consumeGetServerConfig(getconf)

consumeGetServerName: (name) ->
ssh.consumeGetServerName(name)

provider: ->
switch atom.config.get 'julia-client.juliaOptions.bootMode'
provider: (p) ->
@bootMode = undefined
if p?
@bootMode = p
else
@bootMode = atom.config.get('julia-client.juliaOptions.bootMode')
switch @bootMode
when 'Cycler' then cycler
when 'Remote' then ssh
when 'Basic'
switch atom.config.get 'julia-client.consoleOptions.consoleStyle'
switch atom.config.get('julia-client.consoleOptions.consoleStyle')
when 'REPL-based' then basic2
when 'Legacy' then basic

Expand All @@ -28,7 +40,7 @@ module.exports =
process.env.JULIA_EDITOR = "\"#{process.execPath}\" -a"
else
process.env.JULIA_EDITOR = "atom -a"

paths.getVersion()
.then =>
@provider().start? paths.jlpath(), client.clargs()
Expand Down Expand Up @@ -73,16 +85,15 @@ module.exports =
client.flush()
proc

start: ->
start: (provider) ->
[path, args] = [paths.jlpath(), client.clargs()]
paths.projectDir().then (dir) -> cd dir
check = paths.getVersion()

check.catch (err) =>
messages.jlNotFound paths.jlpath(), err

proc = check
.then => @spawnJulia(path, args)
.then => @spawnJulia(path, args, provider)
.then (proc) => if proc.ty? then @monitor2(proc) else @monitor(proc)
proc
.then (proc) =>
Expand All @@ -92,7 +103,12 @@ module.exports =
.catch (e) ->
client.detach()
console.error("Julia exited with #{e}.")
.then =>
if @bootMode is 'Remote'
ssh.withRemoteConfig((conf) -> cd conf.remote).catch ->
else
paths.projectDir().then (dir) -> cd dir
proc

spawnJulia: (path, args) ->
@provider().get(path, args)
spawnJulia: (path, args, provider) ->
@provider(provider).get(path, args)
2 changes: 1 addition & 1 deletion lib/connection/messages.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ module.exports =
client.onceAttached ->
if not msg.isDismissed()
msg.dismiss()
atom.notifications.addSuccess "Julia is connected."
atom.notifications.addSuccess "Julia is connected."
4 changes: 2 additions & 2 deletions lib/connection/process/basic2.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function get_ (path, args) {

function getUnix (path, args, env) {
return new Promise((resolve, reject) => {
tcp.listen().then((port, server) => {
tcp.listen().then((port) => {
paths.fullPath(path).then((path) => {
paths.projectDir().then((cwd) => {
// space before port needed for pty.js on windows:
Expand Down Expand Up @@ -76,7 +76,7 @@ function getWindows (path, args, env) {
return getUnix(path, args, env)
}
return new Promise((resolve, reject) => {
tcp.listen().then((port, server) => {
tcp.listen().then((port) => {
freePort().then((wrapPort) => {
paths.fullPath("powershell").then((psPath) => {
paths.projectDir().then((cwd) => {
Expand Down
Loading