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

feat: Cleanup processes #20

Merged
merged 3 commits into from
Oct 12, 2024
Merged

feat: Cleanup processes #20

merged 3 commits into from
Oct 12, 2024

Conversation

mikew
Copy link
Owner

@mikew mikew commented Oct 12, 2024

Closes #1

@mikew mikew merged commit 944906f into main Oct 12, 2024
2 checks passed
@mikew mikew deleted the cleanup-processes branch October 12, 2024 15:26
mikew added a commit that referenced this pull request Oct 12, 2024
Comment on lines +100 to +102
// We don't want the ssh process ending too early, if it does we can't
// clean up the remote nvim instance.
exec_helpers.PrepareForForking(remoteCmd)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obvious in hindsight, but this breaks logging in via password since the "enter password" bit isn't shown in a terminal.

:(

@mikew mikew mentioned this pull request Oct 13, 2024
mikew added a commit that referenced this pull request Oct 13, 2024
In #20 I changed the SSH process so it
wasn't part of the process group. That was so `ctrl-c` wouldn't
immediately close the SSH process and prevent nvrh from sending a
command to the remote neovim instance and close it.

While that works, it also means that the password prompt isn't shown for
users that don't have an SSH agent / pubkey auth. Since it only applies
to `ctrl-c`, and I don't even think it works on Windows, I'm fine with
disabling it until a better solution is found.

This also switches to `slog` because I need more logging levels than
"print" and "fatal", and adds a `--debug` flag which shows much more
output.

## Preview

When `--debug` is passed

```
[11:42:20.531] INFO: Starting remote nvim {
  "nvimCommandString": " nvim --headless --listen \"/tmp/nvrh-socket-1728830540\" --cmd \"cd Work/nvrh-demo-app\"; [ true = true ] \u0026\u0026 rm -f \"/tmp/nvrh-socket-1728830540\"",
  "source": {
    "file": "/Users/mike/Work/nvrh/src/ssh_helpers/main.go",
    "function": "nvrh/src/ssh_helpers.BuildRemoteNvimCmd",
    "line": 15
  }
}
Pseudo-terminal will not be allocated because stdin is not a terminal.
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
channel 2: open failed: connect failed: open failed
[11:42:22.311] INFO: Connected to nvim {
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.init.func1.2",
    "line": 171
  }
}
[11:42:22.458] INFO: Starting local editor {
  "cmd": [
    "/Applications/Neovide.app/Contents/MacOS/neovide",
    "--server",
    "/var/folders/09/gc_fhm_97csc0w2hlb2wmq_80000gn/T/nvrh-socket-1728830540"
  ],
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.BuildClientNvimCmd",
    "line": 232
  }
}
2024-10-13 11:42:49.822 neovide[95990:8906209] +[IMKClient subclass]: chose IMKClient_Legacy
2024-10-13 11:42:49.822 neovide[95990:8906209] +[IMKInputSession subclass]: chose IMKInputSession_Legacy
[11:42:53.394] INFO: Local editor exited {
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.init.func1.2",
    "line": 197
  }
}
[11:42:53.395] INFO: Closing nvrh {
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.init.func1",
    "line": 214
  }
}
[11:42:53.395] INFO: Closing nvim {
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.closeNvimSocket",
    "line": 369
  }
}
[11:42:53.395] ERROR: Error closing remote nvim {
  "err": "msgpack/rpc: session closed",
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.closeNvimSocket",
    "line": 371
  }
}
[11:42:53.395] DEBUG: Killing command {
  "cmd": [
    "ssh",
    "-L",
    "/var/folders/09/gc_fhm_97csc0w2hlb2wmq_80000gn/T/nvrh-socket-1728830540:/tmp/nvrh-socket-1728830540",
    "-t",
    "vscode-remote",
    "$SHELL -i -c ' nvim --headless --listen \"/tmp/nvrh-socket-1728830540\" --cmd \"cd Work/nvrh-demo-app\"; [ true = true ] \u0026\u0026 rm -f \"/tmp/nvrh-socket-1728830540\"'"
  ],
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.killAllCmds",
    "line": 355
  }
}
[11:42:53.395] DEBUG: Killing command {
  "cmd": [
    "/Applications/Neovide.app/Contents/MacOS/neovide",
    "--server",
    "/var/folders/09/gc_fhm_97csc0w2hlb2wmq_80000gn/T/nvrh-socket-1728830540"
  ],
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.killAllCmds",
    "line": 355
  }
}
[11:42:53.395] ERROR: Error killing command {
  "err": "os: process already finished",
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.killAllCmds",
    "line": 358
  }
}
```

Without `--debug`

```
[11:43:32.096] INFO: Starting remote nvim {
  "nvimCommandString": " nvim --headless --listen \"/tmp/nvrh-socket-1728830612\" --cmd \"cd Work/nvrh-demo-app\"; [ true = true ] \u0026\u0026 rm -f \"/tmp/nvrh-socket-1728830612\""
}
[11:43:33.827] INFO: Connected to nvim
[11:43:33.962] INFO: Starting local editor {
  "cmd": [
    "/Applications/Neovide.app/Contents/MacOS/neovide",
    "--server",
    "/var/folders/09/gc_fhm_97csc0w2hlb2wmq_80000gn/T/nvrh-socket-1728830612"
  ]
}
[11:43:45.095] INFO: Local editor exited
[11:43:45.095] INFO: Closing nvrh
[11:43:45.095] INFO: Closing nvim
[11:43:45.095] ERROR: Error closing remote nvim {
  "err": "msgpack/rpc: session closed"
}
[11:43:45.095] ERROR: Error killing command {
  "err": "os: process already finished"
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cleanup processes
1 participant