Skip to content

Commit

Permalink
fix: change tape error
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelncui committed Dec 13, 2022
1 parent f87ec06 commit 8ccecd8
Show file tree
Hide file tree
Showing 26 changed files with 495 additions and 267 deletions.
4 changes: 2 additions & 2 deletions apis/job_get_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func (api *API) JobGetLog(ctx context.Context, req *entity.JobGetLogRequest) (*e
return &entity.JobGetLogReply{Logs: []byte{}}, nil
}

if req.Offset > 0 {
if _, err := reader.Seek(req.Offset, 0); err != nil {
if req.Offset != nil {
if _, err := reader.Seek(*req.Offset, 0); err != nil {
return nil, fmt.Errorf("seek log file fail, offset= %d, %w", req.Offset, err)
}
}
Expand Down
11 changes: 11 additions & 0 deletions cmd/tape-httpd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"net/http"
"os"
"time"

"github.com/abc950309/tapewriter/apis"
"github.com/abc950309/tapewriter/entity"
Expand All @@ -17,6 +18,7 @@ import (
"github.com/abc950309/tapewriter/resource"
"github.com/abc950309/tapewriter/tools"
"github.com/improbable-eng/grpc-web/go/grpcweb"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -110,6 +112,15 @@ func main() {
Addr: conf.Listen,
}

go func() {
<-tools.ShutdownContext.Done()
logrus.Infof("Graceful shutdown, wait for working process")
start := time.Now()
tools.Wait()
logrus.Infof("Graceful shutdown, wait done, duration= %s", time.Since(start))
srv.Shutdown(context.Background())
}()

log.Printf("http server listening at %v", srv.Addr)
if err := srv.ListenAndServe(); err != nil {
log.Fatalf("failed to serve: %v", err)
Expand Down
46 changes: 29 additions & 17 deletions entity/job_archive.pb.go

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

1 change: 1 addition & 0 deletions entity/job_archive.proto
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ message JobDisplayArchive {
int64 totalFiles = 4;

optional int64 speed = 5;
int64 startTime = 6;
}
Loading

0 comments on commit 8ccecd8

Please sign in to comment.