mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-08 00:22:14 +01:00
fix(chromium): info log into debug log + slight improvement of the killing of stuck processes
This commit is contained in:
@@ -168,36 +168,37 @@ func (b *chromiumBrowser) Stop(logger *zap.Logger) error {
|
|||||||
// See:
|
// See:
|
||||||
// https://github.com/SeleniumHQ/docker-selenium/blob/7216d060d86872afe853ccda62db0dfab5118dc7/NodeChrome/chrome-cleanup.sh
|
// https://github.com/SeleniumHQ/docker-selenium/blob/7216d060d86872afe853ccda62db0dfab5118dc7/NodeChrome/chrome-cleanup.sh
|
||||||
// https://github.com/SeleniumHQ/docker-selenium/blob/7216d060d86872afe853ccda62db0dfab5118dc7/NodeChromium/chrome-cleanup.sh
|
// https://github.com/SeleniumHQ/docker-selenium/blob/7216d060d86872afe853ccda62db0dfab5118dc7/NodeChromium/chrome-cleanup.sh
|
||||||
go func() {
|
|
||||||
// Clean up stuck processes.
|
|
||||||
ps, err := process.Processes()
|
|
||||||
if err != nil {
|
|
||||||
logger.Error(fmt.Sprintf("list processes: %v", err))
|
|
||||||
} else {
|
|
||||||
for _, p := range ps {
|
|
||||||
func() {
|
|
||||||
cmdline, err := p.Cmdline()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !strings.Contains(cmdline, "chromium/chromium") && !strings.Contains(cmdline, "chrome/chrome") {
|
// Clean up stuck processes.
|
||||||
return
|
ps, err := process.Processes()
|
||||||
}
|
if err != nil {
|
||||||
|
logger.Error(fmt.Sprintf("list processes: %v", err))
|
||||||
|
} else {
|
||||||
|
for _, p := range ps {
|
||||||
|
func() {
|
||||||
|
cmdline, err := p.Cmdline()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
killCtx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
if !strings.Contains(cmdline, "chromium/chromium") && !strings.Contains(cmdline, "chrome/chrome") {
|
||||||
defer cancel()
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = p.KillWithContext(killCtx)
|
killCtx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||||
if err != nil {
|
defer cancel()
|
||||||
logger.Error(fmt.Sprintf("kill process: %v", err))
|
|
||||||
} else {
|
err = p.KillWithContext(killCtx)
|
||||||
logger.Info(fmt.Sprintf("Chromium process %d killed", p.Pid))
|
if err != nil {
|
||||||
}
|
logger.Error(fmt.Sprintf("kill process: %v", err))
|
||||||
}()
|
} else {
|
||||||
}
|
logger.Debug(fmt.Sprintf("Chromium process %d killed", p.Pid))
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
// FIXME: Chromium seems to recreate the user profile directory
|
// FIXME: Chromium seems to recreate the user profile directory
|
||||||
// right after its deletion if we do not wait a certain amount
|
// right after its deletion if we do not wait a certain amount
|
||||||
// of time before deleting it.
|
// of time before deleting it.
|
||||||
|
|||||||
Reference in New Issue
Block a user