Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec6645b

Browse files
authored
chore: add parent PID to coder ssh log file name (#16080)
Part of bringing `coder ssh` to parity with `coder vscodessh` isassociating the log files with a particular parent process (in thiscase, the ssh process that spawned the coder CLI via `ProxyCommand`).`coder vscodessh` named log files using the parent PID, but coder ssh ismissing this. Add the parent PID to the log file name when used in stdiomode so that the VS Code extension will be able to identify the correctlog file.See also#16078.
1 parent838ee3b commitec6645b

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

‎cli/ssh.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,26 @@ func (r *RootCmd) ssh() *serpent.Command {
131131
iferr!=nil {
132132
returnxerrors.Errorf("generate nonce: %w",err)
133133
}
134-
logFilePath:=filepath.Join(
135-
logDirPath,
136-
fmt.Sprintf(
137-
"coder-ssh-%s-%s.log",
138-
// The time portion makes it easier to find the right
139-
// log file.
140-
time.Now().Format("20060102-150405"),
141-
// The nonce prevents collisions, as SSH invocations
142-
// frequently happen in parallel.
143-
nonce,
144-
),
134+
logFileBaseName:=fmt.Sprintf(
135+
"coder-ssh-%s-%s",
136+
// The time portion makes it easier to find the right
137+
// log file.
138+
time.Now().Format("20060102-150405"),
139+
// The nonce prevents collisions, as SSH invocations
140+
// frequently happen in parallel.
141+
nonce,
145142
)
143+
ifstdio {
144+
// The VS Code extension obtains the PID of the SSH process to
145+
// find the log file associated with a SSH session.
146+
//
147+
// We get the parent PID because it's assumed `ssh` is calling this
148+
// command via the ProxyCommand SSH option.
149+
logFileBaseName+=fmt.Sprintf("-%d",os.Getppid())
150+
}
151+
logFileBaseName+=".log"
152+
153+
logFilePath:=filepath.Join(logDirPath,logFileBaseName)
146154
logFile,err:=os.OpenFile(
147155
logFilePath,
148156
os.O_CREATE|os.O_APPEND|os.O_WRONLY|os.O_EXCL,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp