Skip to content

Commit 5776eb0

Browse files
committed
Forces TTY usage for interactive sessions
Ensures consistent interactive experiences by always enabling TTY. Removes checks for non-interactive terminals to streamline usage.
1 parent bb36080 commit 5776eb0

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

pkg/cli/exec.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cli
22

33
import (
4-
"os"
54
"strings"
65

76
"github.com/convox/rack/pkg/options"
@@ -28,10 +27,7 @@ func Exec(rack sdk.Interface, c *stdcli.Context) error {
2827
opts.Height = options.Int(h)
2928
opts.Width = options.Int(w)
3029
}
31-
32-
if !stdcli.IsTerminal(os.Stdin) {
33-
opts.Tty = options.Bool(false)
34-
}
30+
opts.Tty = options.Bool(true)
3531

3632
restore := c.TerminalRaw()
3733
defer restore()

pkg/cli/run.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cli
22

33
import (
44
"fmt"
5-
"os"
65
"strings"
76

87
"github.com/convox/rack/pkg/helpers"
@@ -111,10 +110,8 @@ func Run(rack sdk.Interface, c *stdcli.Context) error {
111110
Width: opts.Width,
112111
}
113112

114-
if !stdcli.IsTerminal(os.Stdin) {
115-
eopts.Tty = options.Bool(false)
116-
}
117-
113+
eopts.Tty = options.Bool(true)
114+
fmt.Printf("=======> Options: %+v\n", eopts)
118115
code, err := rack.ProcessExec(app(c), ps.Id, command, c, eopts)
119116
if err != nil {
120117
return err

provider/aws/processes.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,45 @@ func (p *Provider) ProcessExec(app, pid, command string, rw io.ReadWriter, opts
4444
break
4545
}
4646
}
47+
log.Logf("pidFound: %t", pidFound)
48+
log.Logf("pid: %s", pid)
4749

4850
if !pidFound {
51+
log.Error(err)
52+
4953
return -1, errorNotFound(fmt.Sprintf("process id not found for %s", app))
5054
}
5155

5256
dc, err := p.dockerClientFromPid(pid)
5357
if err != nil {
54-
return -1, err
58+
return -1, log.Error(err)
5559
}
5660

5761
c, err := p.dockerContainerFromPid(pid)
5862
if err != nil {
59-
return -1, err
63+
return -1, log.Error(err)
6064
}
65+
log.Logf("container: %s", c.ID)
6166

6267
cmd := []string{"sh", "-c", command}
6368

6469
tty := cb(opts.Tty, true)
70+
log.Logf("tty: %t", tty)
6571

6672
if opts.Entrypoint != nil && *opts.Entrypoint {
6773
cmd = append(c.Config.Entrypoint, cmd...)
6874
} else {
6975
a, err := p.AppGet(app)
7076
if err != nil {
71-
return -1, err
77+
return -1, log.Error(err)
7278
}
7379

7480
if a.Tags["Generation"] == "2" {
7581
cmd = append([]string{"/convox-env"}, cmd...)
7682
}
7783
}
7884

85+
log.Logf("Command: %s", commandString(cmd))
7986
eres, err := dc.CreateExec(docker.CreateExecOptions{
8087
AttachStdin: true,
8188
AttachStdout: true,
@@ -93,7 +100,10 @@ func (p *Provider) ProcessExec(app, pid, command string, rw io.ReadWriter, opts
93100
go func() {
94101
<-success
95102
if opts.Height != nil && opts.Width != nil {
96-
dc.ResizeExecTTY(eres.ID, *opts.Height, *opts.Width)
103+
err := dc.ResizeExecTTY(eres.ID, *opts.Height, *opts.Width)
104+
if err != nil {
105+
log.Error(err)
106+
}
97107
}
98108
success <- struct{}{}
99109
}()
@@ -104,7 +114,7 @@ func (p *Provider) ProcessExec(app, pid, command string, rw io.ReadWriter, opts
104114
InputStream: io.NopCloser(rw),
105115
OutputStream: rw,
106116
ErrorStream: rw,
107-
RawTerminal: true,
117+
RawTerminal: tty,
108118
Success: success,
109119
})
110120

@@ -116,6 +126,7 @@ func (p *Provider) ProcessExec(app, pid, command string, rw io.ReadWriter, opts
116126
if err != nil {
117127
return -1, log.Error(err)
118128
}
129+
log.Logf("ExitCode: %d", ires.ExitCode)
119130

120131
return ires.ExitCode, log.Success()
121132
}

0 commit comments

Comments
 (0)