diff --git a/Dockerfile b/Dockerfile index d840376cd..3b80b05b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,11 +8,15 @@ WORKDIR /app COPY go.mod . COPY go.sum . +# Installing xgo +RUN go install github.com/xhd2015/xgo/cmd/xgo@latest +ENV PATH="/usr/local/xgo/bin:${PATH}" + RUN go mod download COPY . . -RUN CGO_ENABLED=0 go build +RUN CGO_ENABLED=0 xgo build # final stage FROM alpine:latest @@ -24,4 +28,4 @@ COPY --from=builder /app/sphinx-tribes /app/ RUN ls app EXPOSE 5002 -ENTRYPOINT ["/app/sphinx-tribes"] \ No newline at end of file +ENTRYPOINT ["/app/sphinx-tribes"] diff --git a/go.mod b/go.mod index 8b0898986..3a073f373 100644 --- a/go.mod +++ b/go.mod @@ -61,6 +61,7 @@ require ( github.com/onsi/gomega v1.26.0 // indirect github.com/robfig/cron v1.2.0 github.com/urfave/negroni v1.0.0 // indirect + github.com/xhd2015/xgo/runtime v1.0.52 // indirect golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect gopkg.in/go-playground/assert.v1 v1.2.1 // indirect ) diff --git a/go.sum b/go.sum index d389d674c..d4ae95b46 100644 --- a/go.sum +++ b/go.sum @@ -2168,6 +2168,8 @@ github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/urfave/cli v1.22.9/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= +github.com/xhd2015/xgo/runtime v1.0.52 h1:njcRzY3Xo2AFu/qQSC4ak9+JN7xFmaI3iEUyJxoErWM= +github.com/xhd2015/xgo/runtime v1.0.52/go.mod h1:9GBQ2SzJCzpD3T+HRN+2C0TUOGv7qIz4s0mad1xJ8Jo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= diff --git a/routes/index.go b/routes/index.go index 275ab15b7..543ff217e 100644 --- a/routes/index.go +++ b/routes/index.go @@ -9,11 +9,15 @@ import ( "os" "runtime" "time" + "strings" + "context" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" "github.com/rs/cors" "github.com/urfave/negroni" + "github.com/xhd2015/xgo/runtime/core" + "github.com/xhd2015/xgo/runtime/trap" "github.com/stakwork/sphinx-tribes/auth" "github.com/stakwork/sphinx-tribes/config" @@ -195,6 +199,18 @@ func internalServerErrorHandler(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { rr := negroni.NewResponseWriter(w) + trap.AddInterceptor(&trap.Interceptor{ + Pre: func(ctx context.Context, f *core.FuncInfo, args core.Object, results core.Object) (interface{}, error) { + index := strings.Index(f.File, "sphinx-tribes") + trimmed := f.File + if index != -1 { + trimmed = f.File[index:] + } + logger.Log.Machine("%s:%d %s\n", trimmed, f.Line, f.Name) + + return nil, nil + }, + }) defer func() { if err := recover(); err != nil { // Get stack trace