Fiber version
v2.2.0
Issue description
When run dockerized app with prefork enabled it fails with an error straight after starting
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Fiber v2.2.0 โ โ Child PIDs ... 12, 13, 14, 17, 25, 42 โ
โ http://127.0.0.1:80 โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ Handlers ............. 0 Threads ............. 6 โ
โ Prefork ........ Enabled PID ................. 1 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
2020/11/26 14:06:04 exit status 1
No problem with building the container
Also works with prefork disabled
Code snippet
App with prefork
package main
import (
"log"
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New(fiber.Config{
Prefork: true,
})
log.Fatal(app.Listen(":80"))
}
FROM golang:alpine
RUN apk update \
&& apk upgrade \
&& apk --update add --no-cache ca-certificates openssl git tzdata
ENV INSTALL_PATH=/go/src/test/
ENV RUN_PATH=/go/src/test/test
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
ADD . $INSTALL_PATH
RUN go get
RUN go build
CMD ["/bin/sh", "-c", "$RUN_PATH"]
Thanks for opening your first issue here! ๐ Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
Try to use other machine version something that come with full version like golang:1.15.3 or something else without alpine tags
app.go
package main
import (
"log"
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New(fiber.Config{
Prefork: true,
})
log.Fatal(app.Listen(":80"))
}
Dockerfile
FROM golang:1.15.3
ENV INSTALL_PATH=/app
ENV RUN_PATH=./app
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
ADD ./app $INSTALL_PATH
RUN go get
RUN go build -ldflags="-s -w" -o app .
CMD ./app
app structure
.
โโโ Dockerfile
โโโ app
ย ย โโโ app.go
ย ย โโโ go.mod
ย ย โโโ go.sum
@alfuhigi Thanks for sharing the workaround!
I'm facing the same issue, is there no way to use Prefork on Alpine Linux? ๐ค
in https://github.com/gofiber/fiber/blob/master/prefork.go 133 Use PID to exit
// if it is equal to 1 (init process ID),
// it indicates that the master process has exited
for range time.NewTicker(time.Millisecond * 500).C {
if os.Getppid() == 1 {
os.Exit(1)
}
}
on Docker the process start on PID 1
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Fiber v2.2.0 โ โ Child PIDs ... 12, 13, 14, 17, 25, 42 โ
โ http://127.0.0.1:80 โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ Handlers ............. 0 Threads ............. 6 โ
โ Prefork ........ Enabled PID ................. 1 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
So I run the image with docker run -it --pid=host fiber-test and works perfect
reference
โ fiber docker run -it --pid=host fiber-test
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Fiber v2.2.3 โ โ Child PIDs ... 3565, 3566 โ
โ http://127.0.0.1:80 โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ Handlers ............. 0 Processes ........... 2 โ
โ Prefork ........ Enabled PID .............. 3529 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Most helpful comment
in https://github.com/gofiber/fiber/blob/master/prefork.go
133Use PID to exiton Docker the process start on PID 1
So I run the image with
docker run -it --pid=host fiber-testand works perfectreference