Skip to content

Commit

Permalink
Merge pull request #11 from vinyl-linux/make_package_loading_non_fatal
Browse files Browse the repository at this point in the history
Don't drop to shell if service configs are bad on boot
  • Loading branch information
jspc authored Mar 4, 2022
2 parents 13cf740 + 387fc88 commit c62db55
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
go-version: 1.17

- name: Build
run: make
run: |
make -o dispatcher/dispatcher.pb.go -o dispatcher/dispatcher_grpc.pb.go
- name: Test
run: |
Expand Down
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ func Setup() (grpcServer *grpc.Server, err error) {

supervisor, err = New(svcDir)
if err != nil {
return
if _, ok := err.(ConfigParseError); !ok {
return
}

sugar.Warnw("could not load all configs",
"error", err.Error(),
)

err = nil
}

tlsCredentials, err := loadTLSCredentials()
Expand Down
9 changes: 9 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ func TestSetup(t *testing.T) {
}
}

func TestSetup_DodgyServicesJustWarns(t *testing.T) {
svcDir = "testdata/mixed-status-services"

_, err := Setup()
if err != nil {
t.Errorf("unexpected error %#v", err)
}
}

func TestSetup_MissingSvcDir(t *testing.T) {
svcDir = "/tmp/this/dir/hopefully/doesnt/exist"

Expand Down
2 changes: 1 addition & 1 deletion supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *Supervisor) LoadConfigs() (err error) {
}

var svc *Service
cpe := new(ConfigParseError)
cpe := ConfigParseError{}

for _, entry := range entries {
if !entry.IsDir() {
Expand Down

0 comments on commit c62db55

Please sign in to comment.