-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added cleanup script for hanging Chrome processes and temp files #2173
Conversation
PR Description updated to latest commit (b00f2f7)
|
PR Review
✨ Review tool usage guide:Overview:
With a configuration file, use the following template:
See the review usage page for a comprehensive guide on using this tool. |
PR Code Suggestions
✨ Improve tool usage guide:Overview:
With a configuration file, use the following template:
See the improve usage page for a more comprehensive guide on using this tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a good idea. Do you have time to add the same to Edge and Firefox?
I would have to investigate if and where those browsers save their files, but yes. I will check somewhere next week. |
Do you think the older time in seconds (default 1200) and the daemon interval in seconds (default 3600) are able to set different values via an ENV var? |
While creating this PR I was actually thinking that too, yes. Maybe even create an ENV var to disable the cleanup alltogether? I will have a look and update the PR. |
Yes, ENV var to enable/disable is also fine. I see supervisord is used to start the script, so you can disable it in .conf something like docker-selenium/Video/supervisord.conf Lines 40 to 42 in db91598
|
- Allowed cleanup to be enabled and/or configured via environment variables - Updated documentation with new options
I've updated the PR with your comments:
|
LGTM! How about you, @diemol ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we leave SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP
enabled by default?
Several folks use these images for web scraping; sessions could last longer than an hour.
What do you all think?
Fair point. I thought about this as well. Maybe it is better to err on the side of caution, and leave the cleanup disabled by default. I have changed the default value to
Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @cedricroijakkers!
@VietND96 feel free to merge whenever you have time. Thanks!
User description
Description
Added a script (running as a daemon of sorts under supervisord) to clean up files and processes left there by the Chrome browser.
Motivation and Context
We've been running a Selenium grid for quite some time, using it to execute all kinds of automated monitoring tasks on websites, both running in the internal network and on the internet.
Since we're using the Chrome browser exclusively and our grids are long-running, we've noticed that after some time two types of items remain in the containers (consuming PIDs and disk space):
/tmp/.com.google.Chrome.*
, after some time these consume quite a lot of disk space, blowing up the container file system.I have created a shell script that cleans up these two items which runs once an hour. Temporary files on disk will be removed immediately, Chrome processes after they have been active for over 2 hours. This is what we are doing in our setup using an ugly hack by doing it as part of the Docker healthcheck, and it solved all our capacity problems.
The script has only been added to the Chrome node image, since I cannot tell if the same issue is also present on other browsers. Even if it is, the fix will be different since the browser is different, so the change is not applicable there.
A new script has been added under
/opt/bin/chrome-cleanup.sh
in the container, and a supervisord service is added using configuration file/etc/supervisor/conf.d/chrome-cleanup.conf
.Types of changes
Checklist
Type
Bug fix, Enhancement
Description
chrome-cleanup.sh
) to clean up hanging Chrome processes and temporary files in the NodeChrome Docker image.chrome-cleanup.conf
), ensuring it runs continuously as a daemon.Changes walkthrough
chrome-cleanup.sh
Add Chrome Cleanup Daemon Script
NodeChrome/chrome-cleanup.sh
processes.
targeted.
Dockerfile
Integrate Chrome Cleanup Script into Docker Image
NodeChrome/Dockerfile
the Docker image.
chrome-cleanup.conf
Supervisord Configuration for Chrome Cleanup
NodeChrome/chrome-cleanup.conf
script.