Skip to content

fix: Display proper access URL on server start #1172

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

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func server() *cobra.Command {
if !hasFirstUser && err == nil {
// This could fail for a variety of TLS-related reasons.
// This is a helpful starter message, and not critical for user interaction.
_, _ = 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")))
_, _ = 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")))
}
}

Expand Down
21 changes: 10 additions & 11 deletions provisionerd/provisionerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ type Server struct {
shutdown chan struct{}

// Locked when acquiring or failing a job.
jobMutex sync.Mutex
jobID string
jobRunning chan struct{}
jobFailed atomic.Bool
jobCancel context.CancelFunc
jobMutex sync.Mutex
jobID string
jobRunningMutex sync.Mutex
jobRunning chan struct{}
jobFailed atomic.Bool
jobCancel context.CancelFunc
}

// Connect establishes a connection to coderd.
Expand All @@ -116,13 +117,10 @@ func (p *Server) connect(ctx context.Context) {
if errors.Is(err, context.Canceled) {
return
}
p.closeMutex.Lock()
if p.isClosed() {
p.closeMutex.Unlock()
return
}
p.opts.Logger.Warn(context.Background(), "failed to dial", slog.Error(err))
p.closeMutex.Unlock()
continue
}
p.clientValue.Store(client)
Expand Down Expand Up @@ -230,11 +228,10 @@ func (p *Server) acquireJob(ctx context.Context) {
if job.JobId == "" {
return
}
if p.isClosed() {
return
}
ctx, p.jobCancel = context.WithCancel(ctx)
p.jobRunningMutex.Lock()
p.jobRunning = make(chan struct{})
p.jobRunningMutex.Unlock()
p.jobFailed.Store(false)
p.jobID = job.JobId

Expand Down Expand Up @@ -938,7 +935,9 @@ func (p *Server) closeWithError(err error) error {
errMsg = err.Error()
}
p.failActiveJobf(errMsg)
p.jobRunningMutex.Lock()
<-p.jobRunning
p.jobRunningMutex.Unlock()
p.closeCancel()

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