Skip to content

Instantly share code, notes, and snippets.

@randria
Last active March 26, 2025 08:03
Show Gist options
  • Save randria/567c1717e6b8f8c4c36f3a3fb8362c0a to your computer and use it in GitHub Desktop.
Save randria/567c1717e6b8f8c4c36f3a3fb8362c0a to your computer and use it in GitHub Desktop.
squid with launchd

Start squid using launchd

  • create the plist file in
    ~/Library/LaunchAgents/com.squid-cache.org.daemon.plist
  • create a local state directory
    mkdir -p ${HOME}/.local/state/squid
  • do check format
    plutil -lint ~/Library/LaunchAgents/com.squid-cache.org.daemon.plist
  • Then load the job with
    launchctl load ~/Library/LaunchAgents/com.squid-cache.org.daemon.plist
  • You should see the PID number xxxxx and not - when launched
    launchctl list | grep squid
    # xxxxx	0	com.squid-cache.org.daemon.plist

Refs

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.squid-cache.org.daemon.plist</string>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/randriat/.local/state/squid/stderr.log</string>
<key>StandardOutPath</key>
<string>/Users/randriat/.local/state/squid/stdout.log</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/sbin/squid</string>
<string>--foreground</string>
<string>-d 5</string>
<string>-YC</string>
</array>
<key>OnDemand</key>
<false/>
</dict>
</plist>
@randria
Copy link
Author

randria commented Mar 26, 2025

Error: Bootstrap failed

Bootstrap failed: 5: Input/output error 

is the most misunderstood error in launchd. If you search for it online, you will find many reports where people claim "this error means ..." and "doing ... will fix it", but neither is true. This error just means that there was an I/O error while trying to bootstrap the service. Basically, any I/O error will trigger this message, so it means absolutely nothing in particular, as there are many reasons and causes.

Here is a non-exhaustive list of possible causes:

  • The referenced plist does not exist.
  • The referenced plist cannot be read due to permissions/ownership.
  • The referenced plist is not a well-formatted plist.
  • The referenced plist contains invalid UTF-8 characters. <-- our case here
  • The referenced plist does not match the documented format (man launchd.plist).
  • launchctl failed to communicate with launchd via IPC for some reason.
  • launchd returns an I/O error via IPC.
  • A job of that name is already loaded, in which case no job entry can be created for that name.

source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment