Skip to content

Commit 5a017cb

Browse files
committed
update doc
1 parent ea55e04 commit 5a017cb

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

custom-launch.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ Here are the available flags: [link](https://peter.sh/experiments/chromium-comma
108108

109109
Read the API doc for more info: [link](https://pkg.go.dev/github.com/go-rod/rod/lib/launcher#Launcher).
110110

111+
## Cleanup
112+
113+
By default, the browser will create a [user-data-dir](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md)
114+
to store the user data, such as cookies, cache, etc.
115+
Rod provides a helper function `Cleanup` to remove it after the browser is fully closed:
116+
117+
```go
118+
func main() {
119+
l := launcher.New().
120+
Headless(false).
121+
Devtools(true)
122+
123+
defer l.Cleanup()
124+
}
125+
```
126+
111127
## Remotely manage the launcher :id=remotely-manage-the-launcher
112128

113129
For production scraping system, usually, we will separate the scrapers and browsers into different clusters so that
@@ -124,7 +140,8 @@ Here's an example to use it:
124140
2. Open another terminal and run code like this [example](https://github.com/go-rod/rod/blob/main/lib/examples/launch-managed/main.go)
125141

126142
The image is [tuned](https://github.com/go-rod/rod/blob/main/lib/docker/Dockerfile) for screenshots and fonts among popular natural languages.
127-
Each container can launch multiple browsers at the same time.
143+
Each container can launch multiple browsers at the same time. The manager will automatically remove the [user-data-dir](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md)
144+
when the control connection is closed.
128145

129146
## User mode :id=user-mode
130147

0 commit comments

Comments
 (0)