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
- func NoSandbox(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 Headless(path string, port int) CommandLineOption
- func LimitCoreDump(sz ByteCount) CommandLineOption
- func LimitMemory(mem ByteCount) CommandLineOption
- func Path(path string) CommandLineOption
- func Port(port int) CommandLineOption
- func ProcessOpt(o func(*os.Process) error) CommandLineOption
- func Proxy(proxy string) CommandLineOption
- func ProxyPacURL(pacURL url.URL) CommandLineOption
- func Rlimit(res int, cur, max uint64) CommandLineOption
- func StartMaximized() 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 is a Chrome command line option to set the exec 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 Headless ¶
func Headless(path string, port int) CommandLineOption
Headless is the Chrome command line option to set the default settings for running the headless_shell executable. If path is empty, then an attempt will be made to find headless_shell on the path.
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 Path ¶
func Path(path string) CommandLineOption
Path sets the path to the Chrome executable and sets default run options for Chrome. This will also set the remote debugging port to 9222, and disable the first run / default browser check.
Note: use ExecPath if you do not want to set other options.
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 outbound proxy.
func ProxyPacURL ¶
func ProxyPacURL(pacURL url.URL) CommandLineOption
ProxyPacURL is the Chrome command line option to set the URL of a proxy PAC file.
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 StartMaximized ¶
func StartMaximized() CommandLineOption
StartMaximized is the Chrome command line option to start with maximized window size.
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.