Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
fix: Set timeouts for restarts, use bash explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
pojntfx committed Oct 26, 2021
1 parent 6b303ca commit 51d5a04
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/api/proto/v1/dhclient.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/api/proto/v1/dhcpd.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/api/proto/v1/index.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pkg/services/dhclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package services
import (
"context"
"os"
"time"

api "github.com/pojntfx/go-isc-dhcp/pkg/api/proto/v1"
"github.com/pojntfx/go-isc-dhcp/pkg/workers"
Expand Down Expand Up @@ -40,7 +41,9 @@ func (m *DHClientManager) Create(_ context.Context, args *api.DHClient) (*api.DH
// Keep the dhcp client running
for {
if !dhcpd.IsScheduledForDeletion() {
log.Info("Restarting dhcp client")
log.Info("dhcp client crashed, restarting in 1 second")

time.Sleep(time.Second)

if err := dhcpd.Start(); err != nil {
log.Error(err.Error())
Expand Down
7 changes: 5 additions & 2 deletions pkg/services/dhcpd.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package services

//go:generate sh -c "mkdir -p ../api/proto/v1 && protoc --go_out=paths=source_relative,plugins=grpc:../api/proto/v1 -I=../../api/proto/v1 ../../api/proto/v1/*.proto"
//go:generate bash -c "mkdir -p ../api/proto/v1 && protoc --go_out=paths=source_relative,plugins=grpc:../api/proto/v1 -I=../../api/proto/v1 ../../api/proto/v1/*.proto"

import (
"context"
"os"
"path/filepath"
"time"

api "github.com/pojntfx/go-isc-dhcp/pkg/api/proto/v1"
"github.com/pojntfx/go-isc-dhcp/pkg/workers"
Expand Down Expand Up @@ -94,7 +95,9 @@ func (m *DHCPDManager) Create(_ context.Context, args *api.DHCPD) (*api.DHCPDMan
// Keep the dhcp server running
for {
if !dhcpd.IsScheduledForDeletion() {
log.Info("Restarting dhcp server")
log.Info("dhcp server crashed, restarting in 1 second")

time.Sleep(time.Second)

if err := dhcpd.Start(); err != nil {
log.Error(err.Error())
Expand Down
3 changes: 2 additions & 1 deletion pkg/workers/dhcpd.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package workers

//go:generate sh -c "rm -rf dhcp && git clone https://gitlab.isc.org/isc-projects/dhcp.git && cd dhcp && ./configure $(echo $([ -v CC ] && echo --host=${CC})) && make"
//go:generate bash -c "rm -rf dhcp && git clone --depth 1 https://gitlab.isc.org/isc-projects/dhcp.git && cd dhcp && ./configure $(echo $([ -v CC ] && echo --host=${CC})) && make"

import (
_ "embed"
"fmt"
"os"

"os/exec"
"path/filepath"
"strings"
Expand Down

0 comments on commit 51d5a04

Please sign in to comment.