Skip to content
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

Gracefully handle startup errors #4383

Merged
merged 30 commits into from
Sep 22, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
wip
  • Loading branch information
andig committed Sep 21, 2022
commit aedd4fb394e6664002daaffd4f0bc161b123394e
27 changes: 13 additions & 14 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,19 @@ func run(cmd *cobra.Command, args []string) {

// allow web access for vehicles
cp.webControl(conf.Network, httpd.Router(), valueChan)
} else {
// delayed reboot on error
const reboot = time.Minute

log.FATAL.Println(err)
log.FATAL.Printf("will attempt restart in: %v", reboot)

publish("fatal", err)

time.AfterFunc(reboot, func() {
os.Exit(1)
})

}

stopC := make(chan struct{})
Expand All @@ -277,20 +290,6 @@ func run(cmd *cobra.Command, args []string) {
close(siteC)
}()

// delayed reboot on error
if err != nil {
const reboot = time.Minute

log.FATAL.Println(err)
log.FATAL.Printf("will attempt restart in: %v", reboot)

publish("fatal", err)

time.AfterFunc(reboot, func() {
os.Exit(1)
})
}

// uds health check listener
go server.HealthListener(site, siteC)

Expand Down