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

Fix json escaped character handling #65

Merged
merged 6 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 2 additions & 12 deletions cmd/axiom-syslog-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"flag"
"os"
"os/signal"
"syscall"

"github.com/axiomhq/axiom-go/axiom"
"github.com/axiomhq/pkg/cmd"
Expand Down Expand Up @@ -40,15 +38,7 @@ func run(ctx context.Context, _ *zap.Logger, client *axiom.Client) error {
return cmd.Error("create server", err)
}

// Setup cancellation context that will be cancelled on receiving a signal
ctx, stop := signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM)
defer stop()
srv.Run(ctx)

go func() {
srv.Run()
}()

<-ctx.Done()

return ctx.Err()
return nil
}
6 changes: 3 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ func (srv *Server) Flush() error {
return nil
}

func (srv *Server) Run() {
func (srv *Server) Run(ctx context.Context) {
if srv.started {
log.Print("server already running")
return
}

srv.started = true
ticker := time.NewTicker(5 * time.Second)
done := make(chan bool)

for {
select {
case <-done:
case <-ctx.Done():
srv.Flush()
Rambatino marked this conversation as resolved.
Show resolved Hide resolved
return
case <-ticker.C:
srv.Flush()
Expand Down