Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Small Fixes (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Otterverse authored Mar 8, 2024
1 parent fc11bc0 commit 820087c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ bin/golangci-lint:
lint: bin/golangci-lint
go mod tidy
bin/golangci-lint run -v --fix

.PHONY: upload-stable
upload-stable: bin/viam-agent-provisioning-$(PATH_VERSION)-x86_64 bin/viam-agent-provisioning-$(PATH_VERSION)-aarch64 bin/viam-agent-provisioning-stable-x86_64 bin/viam-agent-provisioning-stable-aarch64
test "$(PATH_VERSION)" != "custom"
gsutil -h "Cache-Control:no-cache" cp bin/viam-agent-provisioning-$(PATH_VERSION)-x86_64 bin/viam-agent-provisioning-$(PATH_VERSION)-aarch64 bin/viam-agent-provisioning-stable-x86_64 bin/viam-agent-provisioning-stable-aarch64 gs://packages.viam.com/apps/viam-agent-provisioning/
18 changes: 7 additions & 11 deletions cmd/viam-agent-provisioning/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ var (
)

func main() {
ctx := setupExitSignalHandling()
defer activeBackgroundWorkers.Wait()

//nolint:lll
var opts struct {
Config string `default:"/opt/viam/etc/agent-provisioning.json" description:"Path to config file" long:"config" short:"c"`
Expand All @@ -44,7 +41,9 @@ func main() {
parser.Usage = "runs as a background service and manages updates and the process lifecycle for viam-server."

_, err := parser.Parse()
exitIfError(err)
if err != nil {
log.Fatal(err)
}

if opts.Help {
var b bytes.Buffer
Expand All @@ -64,6 +63,9 @@ func main() {
log = golog.NewDebugLogger("agent-provisioning")
}

ctx := setupExitSignalHandling()
defer activeBackgroundWorkers.Wait()

pCfg, err := provisioning.LoadProvisioningConfig(opts.ProvisioningConfig)
if err != nil {
log.Error(errw.Wrapf(err, "error loading %s, using defaults", opts.ProvisioningConfig))
Expand Down Expand Up @@ -126,7 +128,7 @@ func setupExitSignalHandling() context.Context {
case syscall.SIGABRT:
fallthrough
case syscall.SIGTERM:
log.Info("exiting")
log.Info("exit signal received")
signal.Ignore(os.Interrupt, syscall.SIGTERM, syscall.SIGABRT) // keeping SIGQUIT for stack trace debugging
return

Expand All @@ -150,9 +152,3 @@ func setupExitSignalHandling() context.Context {
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM, syscall.SIGABRT, syscall.SIGUSR1)
return ctx
}

func exitIfError(err error) {
if err != nil {
log.Fatal(err)
}
}

0 comments on commit 820087c

Please sign in to comment.