diff options
author | Alan Pearce | 2024-05-18 20:23:27 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-18 20:23:27 +0200 |
commit | 7dc19d115c5f3b012f96284adc8cadb9b703d6db (patch) | |
tree | 663783920a624046fed7618dc1bdf1bbf389aaf3 /cmd | |
parent | 9a10bbdb7ab8cb4da1002729b463ed9beca13858 (diff) | |
download | website-7dc19d115c5f3b012f96284adc8cadb9b703d6db.tar.lz website-7dc19d115c5f3b012f96284adc8cadb9b703d6db.tar.zst website-7dc19d115c5f3b012f96284adc8cadb9b703d6db.zip |
remove lint errors
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/dev/main.go | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/cmd/dev/main.go b/cmd/dev/main.go index 1a6ccea..aa3102f 100644 --- a/cmd/dev/main.go +++ b/cmd/dev/main.go @@ -36,7 +36,11 @@ type DevConfig struct { ServerURL config.URL `conf:"default:http://localhost:3001"` } -func RunCommandPiped(ctx context.Context, command string, args ...string) (cmd *exec.Cmd, err error) { +func RunCommandPiped( + ctx context.Context, + command string, + args ...string, +) (cmd *exec.Cmd, err error) { slog.Debug(fmt.Sprintf("running command %s %s", command, strings.Join(args, " "))) cmd = exec.CommandContext(ctx, command, args...) cmd.Env = append(os.Environ(), "DEBUG=") @@ -128,7 +132,7 @@ func server(ctx context.Context, devConfig DevConfig) error { done := make(chan struct{}) err = cmd.Start() if err != nil { - return errors.WithMessage(err, fmt.Sprintf("error starting server binary")) + return errors.WithMessage(err, "error starting server binary") } go func() { @@ -145,7 +149,10 @@ func server(ctx context.Context, devConfig DevConfig) error { select { case <-ctx.Done(): slog.Debug("server context done") - cmd.Process.Signal(os.Interrupt) + err := cmd.Process.Signal(os.Interrupt) + if err != nil { + return err + } <-done case err := <-cmdErr: return err @@ -219,15 +226,12 @@ func main() { done <- true }() go func() { - for { - select { - case ready := <-serverChan: - if ready { - slog.Debug("sending reload message") - eventsource.SendEventMessage("reload", "", "") - } else { - slog.Debug("server not ready") - } + for ready := range serverChan { + if ready { + slog.Debug("sending reload message") + eventsource.SendEventMessage("reload", "", "") + } else { + slog.Debug("server not ready") } } }() @@ -274,7 +278,10 @@ loop: case <-ctx.Done(): slog.Debug("main context cancelled") slog.Debug("calling server shutdown") - srv.Shutdown(devCtx) + err := srv.Shutdown(devCtx) + if err != nil { + slog.Debug("shutdown error", "error", err) + } exitCode = 1 break loop case event := <-fw.Events: @@ -291,10 +298,8 @@ loop: slog.Error(fmt.Sprintf("server reported error: %v", err)) if errors.As(err, &exerr) { slog.Debug("server exit error") - exitCode = exerr.ExitCode() } else { slog.Debug("server other error") - exitCode = 1 } break } |