mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-15 11:52:14 +01:00
adds configurable debugging of startup of processes and print out some info from the chrome viable() function for debugging purposes
This commit is contained in:
@@ -7,15 +7,19 @@ import (
|
||||
"github.com/mafredri/cdp/devtool"
|
||||
)
|
||||
|
||||
const (
|
||||
warmupTime = 10 * time.Second
|
||||
)
|
||||
|
||||
type chrome struct {
|
||||
manager *processManager
|
||||
}
|
||||
|
||||
// NewChrome retruns a Google Chrome
|
||||
// headless process.
|
||||
func NewChrome() Process {
|
||||
func NewChrome(debug bool) Process {
|
||||
return &chrome{
|
||||
manager: &processManager{},
|
||||
manager: &processManager{verbose: debug},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,12 +62,20 @@ func (p *chrome) viable() bool {
|
||||
// check if Google Chrome is correctly running.
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
_, err := devtool.New("http://localhost:9222").Version(ctx)
|
||||
return err == nil
|
||||
p.manager.notifyf(`%v: checking Chrome liveness via debug version endpoint
|
||||
'http://localhost:9222/json/version'`, p.name())
|
||||
v, err := devtool.New("http://localhost:9222").Version(ctx)
|
||||
if err != nil {
|
||||
p.manager.notifyf("%v: Chrome version endpoint returned error: %v", p.name(), err)
|
||||
return false
|
||||
}
|
||||
p.manager.notifyf("%v: Chrome returned version info: %+v", p.name(), *v)
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *chrome) warmup() {
|
||||
time.Sleep(5 * time.Second)
|
||||
p.manager.notifyf("%v: allowing Chrome %v to startup", p.name(), warmupTime)
|
||||
time.Sleep(warmupTime)
|
||||
}
|
||||
|
||||
// Compile-time checks to ensure type implements desired interfaces.
|
||||
|
||||
Reference in New Issue
Block a user