Documentation ¶
Overview ¶
Package runner provides a Chrome process runner.
Index ¶
- Constants
- func ForceKill(m map[string]interface{}) error
- func KillProcessGroup(m map[string]interface{}) error
- type ByteCount
- type CommandLineOption
- func CmdOpt(o func(*exec.Cmd) error) CommandLineOption
- func ExecPath(path string) CommandLineOption
- func Flag(name string, value interface{}) CommandLineOption
- func LimitCoreDump(sz ByteCount) CommandLineOption
- func LimitMemory(mem ByteCount) CommandLineOption
- func Port(port int) CommandLineOption
- func ProcessOpt(o func(*os.Process) error) CommandLineOption
- func Proxy(proxy string) CommandLineOption
- func Rlimit(res int, cur, max uint64) CommandLineOption
- func StartURL(urlstr string) CommandLineOption
- func UserAgent(userAgent string) CommandLineOption
- func UserDataDir(dir string) CommandLineOption
- func WindowSize(width, height int) CommandLineOption
- type Runner
- func (r *Runner) Client(opts ...client.Option) *client.Client
- func (r *Runner) Port() int
- func (r *Runner) Shutdown(ctxt context.Context, opts ...client.Option) error
- func (r *Runner) Start(ctxt context.Context) error
- func (r *Runner) Wait() error
- func (r *Runner) WatchPageTargets(ctxt context.Context, opts ...client.Option) <-chan client.Target
Constants ¶
const (
// DefaultChromePath is the default path to the google-chrome executable.
DefaultChromePath = "/usr/bin/google-chrome"
)
const (
// DefaultUserDataDirPrefix is the default user data directory prefix.
DefaultUserDataDirPrefix = "chromedp-runner.%d."
)
const ( // DefaultUserDataTmpDir is the default directory path for created user // data directories. DefaultUserDataTmpDir = "/tmp" )
Variables ¶
This section is empty.
Functions ¶
func ForceKill ¶
ForceKill is a Chrome command line option that forces Chrome to be killed when the parent is killed.
Note: sets exec.Cmd.SysProcAttr.Setpgid = true (only for Linux)
func KillProcessGroup ¶
KillProcessGroup is a Chrome command line option that will instruct the invoked child Chrome process to terminate when the parent process (ie, the Go application) dies.
Note: sets exec.Cmd.SysProcAttr.Setpgid = true and does nothing on Windows.
Types ¶
type CommandLineOption ¶
CommandLineOption is a Chrome command line option.
see: http://peter.sh/experiments/chromium-command-line-switches/
func CmdOpt ¶
func CmdOpt(o func(*exec.Cmd) error) CommandLineOption
CmdOpt is a Chrome command line option to modify the underlying exec.Cmd prior to invocation.
func ExecPath ¶
func ExecPath(path string) CommandLineOption
ExecPath sets the Chrome executable path.
func Flag ¶
func Flag(name string, value interface{}) CommandLineOption
Flag is a generic Chrome command line option to pass a name=value flag to Chrome.
func LimitCoreDump ¶
func LimitCoreDump(sz ByteCount) CommandLineOption
LimitCoreDump is a Chrome command line option to set the soft core dump limit for a running Chrome process.
Note: uses Linux prlimit system call, and is invoked after the child process has been started.
func LimitMemory ¶
func LimitMemory(mem ByteCount) CommandLineOption
LimitMemory is a Chrome command line option to set the soft memory limit for a running Chrome process.
Note: uses Linux prlimit system call, and is invoked after the child process has been started.
func Port ¶
func Port(port int) CommandLineOption
Port is the Chrome command line option to set the remote debugging port.
func ProcessOpt ¶
func ProcessOpt(o func(*os.Process) error) CommandLineOption
ProcessOpt is a Chrome command line option to modify the child os.Process after started exec.Cmd.Start.
func Proxy ¶
func Proxy(proxy string) CommandLineOption
Proxy is the Chrome command line option to set the proxy used.
func Rlimit ¶
func Rlimit(res int, cur, max uint64) CommandLineOption
Rlimit is a Chrome command line option to set the soft rlimit value for res on a running Chrome process.
Note: uses Linux prlimit system call, and is invoked after the child process has been started.
see: man 2 prlimit
func StartURL ¶
func StartURL(urlstr string) CommandLineOption
StartURL is the Chrome command line option to set the initial URL.
func UserAgent ¶
func UserAgent(userAgent string) CommandLineOption
UserAgent is the Chrome command line option to set the default User-Agent header.
func UserDataDir ¶
func UserDataDir(dir string) CommandLineOption
UserDataDir is the Chrome command line option to set the user data dir.
func WindowSize ¶
func WindowSize(width, height int) CommandLineOption
WindowSize is the Chrome command line option to set the initial window size.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner holds information about a running Chrome process.
func New ¶
func New(opts ...CommandLineOption) (*Runner, error)
New creates a new Chrome process using the supplied command line options.
func Run ¶
func Run(ctxt context.Context, opts ...CommandLineOption) (*Runner, error)
Run starts a new Chrome process runner, using the provided context and command line options.
func (*Runner) Client ¶
Client returns a Chrome Debugging Protocol client for the running Chrome process.
func (*Runner) Start ¶
Start starts a Chrome process using the specified context. The Chrome process can be terminated by closing the passed context.