Cronbot Is Now Written In Go
Cronbot is the free, optional service in Docket Cache that pings your site every hour. Its main job is to make sure the Docket Cache garbage collector runs, even when nobody visits your site. We have rewritten the Cronbot server in Go. The new server is already live, and you do not need to change anything on your site.
Why Docket Cache needs a ping#
Docket Cache keeps its cache as files on disk. The garbage collector keeps that folder in good shape. It is a WordPress scheduled task that runs every 5 minutes, and it does four things.
- removes cache files that have expired
- removes files when the cache has more files, or uses more disk space, than its limits allow
- removes stale cache that WordPress, WooCommerce and other plugins leave behind after they clear their own cache, when that option is turned on
- collects the cache statistics
The problem is that WordPress scheduled tasks, called WP-Cron, only run when someone visits your site. On a quiet site, the garbage collector can go hours without running, and the cache folder can grow past its limits. On shared hosting, that can mean too many files or too much disk space. On a site that turns WP-Cron off with DISABLE_WP_CRON, the garbage collector does not run at all unless something else starts it.
Cronbot is that something else. Once you connect, Cronbot pings your site every hour. Each ping runs the scheduled tasks that are due. Most importantly, that includes the garbage collector, but it also runs other WordPress tasks, such as publishing scheduled posts, sending emails and checking for updates.
Connecting your site#
Cronbot is off by default. To turn it on, open the Cronbot screen of Docket Cache in the WordPress admin and click Connect. The same screen lists your site's cron events and when each one will run next.
After you connect, the screen shows when the last ping arrived and when the next one is due. Click Test Ping at any time to check that Cronbot can reach your site. To stop, click Disconnect.
Why we rewrote it#
The first Cronbot server was a small PHP project. A cron job on the server started a shell script, which used GNU parallel to start a new PHP process for every ping, 3 at a time. Each connected site had its own PHP data file.
That worked well for years. Today, about 3,500 sites are connected, and the old design was starting to show its age. Many small parts had to work together, pings could only go out 3 at a time, and there was no easy way to see what happened over a day or a month.
What is better#
- One program. The new server is a single Go program with one SQLite database. It replaces the cron job, the shell script, GNU parallel and the PHP code.
- More pings at once. It sends up to 20 pings at a time, instead of 3, so pings arrive closer to their planned time.
- Kind to shared hosts. It pings each site, and each host, only once at a time. A server with many connected sites is not hit by many pings together.
- Safer. It refuses to ping private network addresses, and it rejects site addresses that are not real web addresses.
- A history of every ping. Each ping and each Connect request is saved, in one file per month. This helps us find problems and see how the service is doing.
- A public status page. cronbot.docketcache.com shows how many sites are connected and how the pings of the last 24 hours went. It shows totals only, never site addresses.
What stays the same#
- No update needed. The new server speaks exactly the same language as the old one, so every installed version of Docket Cache keeps working.
- The same address and IP. Cronbot still runs at cronbot.docketcache.com from the same IP address. If your firewall allows that address, it still works.
- The same rules. Cronbot pings every hour. If your site is busy or times out, it waits a little longer. If it answers with an error, it waits 2 hours. After more than 5 failed pings in a row, Cronbot stops, because the plugin was probably turned off or removed. If that happens by mistake, the plugin checks its connection every 90 minutes and connects again by itself.
What Cronbot knows about your site#
To connect, the plugin sends your site address, your timezone, your Docket Cache and WordPress versions, and, on a multisite network, the number of networks and sites. The server also sees the IP address the request comes from. After each ping, your site sends a short reply about the tasks it ran.
Cronbot never sees your posts, your users or your passwords. We use this data only to run the service and to learn which versions of WordPress and Docket Cache are in use.
Keeping it free#
Cronbot is a free service, and running a server for thousands of sites costs money. If Cronbot helps you, please think about sponsoring Docket Cache. Read more in Our First Merchandise.