Skip to content

Commit 3830ca6

Browse files
committed
fix: Display proper access URL on server start (#1172)
Fixes #1170.
1 parent 1975aa9 commit 3830ca6

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

cli/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ func server() *cobra.Command {
293293
if !hasFirstUser && err == nil {
294294
// This could fail for a variety of TLS-related reasons.
295295
// This is a helpful starter message, and not critical for user interaction.
296-
_, _ = fmt.Fprint(cmd.ErrOrStderr(), cliui.Styles.Paragraph.Render(cliui.Styles.Wrap.Render(cliui.Styles.FocusedPrompt.String()+`Run `+cliui.Styles.Code.Render("coder login "+client.URL.String())+" in a new terminal to get started.\n")))
296+
_, _ = fmt.Fprint(cmd.ErrOrStderr(), cliui.Styles.Paragraph.Render(cliui.Styles.Wrap.Render(cliui.Styles.FocusedPrompt.String()+`Run `+cliui.Styles.Code.Render("coder login "+accessURL)+" in a new terminal to get started.\n")))
297297
}
298298
}
299299

provisionerd/provisionerd.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,12 @@ type Server struct {
9999
shutdown chan struct{}
100100

101101
// Locked when acquiring or failing a job.
102-
jobMutex sync.Mutex
103-
jobID string
104-
jobRunning chan struct{}
105-
jobFailed atomic.Bool
106-
jobCancel context.CancelFunc
102+
jobMutex sync.Mutex
103+
jobID string
104+
jobRunningMutex sync.Mutex
105+
jobRunning chan struct{}
106+
jobFailed atomic.Bool
107+
jobCancel context.CancelFunc
107108
}
108109

109110
// Connect establishes a connection to coderd.
@@ -116,13 +117,10 @@ func (p *Server) connect(ctx context.Context) {
116117
if errors.Is(err, context.Canceled) {
117118
return
118119
}
119-
p.closeMutex.Lock()
120120
if p.isClosed() {
121-
p.closeMutex.Unlock()
122121
return
123122
}
124123
p.opts.Logger.Warn(context.Background(), "failed to dial", slog.Error(err))
125-
p.closeMutex.Unlock()
126124
continue
127125
}
128126
p.clientValue.Store(client)
@@ -230,11 +228,10 @@ func (p *Server) acquireJob(ctx context.Context) {
230228
if job.JobId == "" {
231229
return
232230
}
233-
if p.isClosed() {
234-
return
235-
}
236231
ctx, p.jobCancel = context.WithCancel(ctx)
232+
p.jobRunningMutex.Lock()
237233
p.jobRunning = make(chan struct{})
234+
p.jobRunningMutex.Unlock()
238235
p.jobFailed.Store(false)
239236
p.jobID = job.JobId
240237

@@ -938,7 +935,9 @@ func (p *Server) closeWithError(err error) error {
938935
errMsg = err.Error()
939936
}
940937
p.failActiveJobf(errMsg)
938+
p.jobRunningMutex.Lock()
941939
<-p.jobRunning
940+
p.jobRunningMutex.Unlock()
942941
p.closeCancel()
943942

944943
p.opts.Logger.Debug(context.Background(), "closing server with error", slog.Error(err))

0 commit comments

Comments
 (0)