diff --git a/thumbnail/handler/thumbnail.go b/thumbnail/handler/thumbnail.go index ac24310..6de7b80 100644 --- a/thumbnail/handler/thumbnail.go +++ b/thumbnail/handler/thumbnail.go @@ -5,6 +5,7 @@ import ( "encoding/base64" "fmt" "io/ioutil" + "os" "os/exec" "path/filepath" "time" @@ -31,6 +32,9 @@ func NewThumbnail(imageService iproto.ImageService) *Thumbnail { func (e *Thumbnail) Screenshot(ctx context.Context, req *thumbnail.ScreenshotRequest, rsp *thumbnail.ScreenshotResponse) error { imageName := uuid.New().String() + ".png" imagePath := filepath.Join(screenshotPath, imageName) + defer func() { + os.Remove(imagePath) + }() width := "800" height := "600" if req.Width != 0 { @@ -39,8 +43,10 @@ func (e *Thumbnail) Screenshot(ctx context.Context, req *thumbnail.ScreenshotReq if req.Height != 0 { height = fmt.Sprintf("%v", req.Height) } - - outp, err := exec.Command("/usr/bin/chromium-browser", "--headless", "--window-size="+width+","+height, "--no-sandbox", "--screenshot="+imagePath, "--hide-scrollbars", req.Url).CombinedOutput() + cmd := exec.Command("/usr/bin/chromium-browser", + "--headless", "--window-size="+width+","+height, "--no-sandbox", "--screenshot="+imagePath, + "--hide-scrollbars", "--disable-setuid-sandbox", "--single-process", "--no-zygote", req.Url) + outp, err := cmd.CombinedOutput() logger.Info(string(outp)) if err != nil { logger.Error(string(outp) + err.Error())