MacOS .plist "RunAtLoad=false" doesn't work

241 Views Asked by At

I recently installed a daemon on my MacOS (cloudflared for Cloud Flare Tunnel, really a great thing to have) and I'm unable to make my mac stop loagind it at start time.

I want it to stop loading at start time, I want to manually start and stop the daemon manually.

I've changed to false the RunAtLoad key in the .plist file inside /Library/LaunchDaemons, but the system is still loading it at start time.

This is the .plist file.

<?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.cloudflare.cloudflared</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/bin/cloudflared</string>
      <string>tunnel</string>
      <string>run</string>
      <string>--token</string>
      <string>[token]]</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StandardOutPath</key>
    <string>/Library/Logs/com.cloudflare.cloudflared.out.log</string>
    <key>StandardErrorPath</key>
    <string>/Library/Logs/com.cloudflare.cloudflared.err.log</string>
    <key>KeepAlive</key> 
    <dict>
    <key>SuccessfulExit</key>
    <false/>
    </dict>
    <key>ThrottleInterval</key>
    <integer>5</integer>
  </dict>
</plist>

Any suggestions?

1

There are 1 best solutions below

0
Giuseppe Lanzi On BEST ANSWER

Setting the AfterInitialDemand key to true does the tick. It makes the job not to start at load time.

This is my final plist.

<!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.cloudflare.cloudflared</string>
                <key>ProgramArguments</key>
                <array>
                        <string>/usr/local/bin/cloudflared</string>
                        <string>tunnel</string>
                        <string>run</string>
                        <string>--token</string>
                        <string>eyJhIjoiMjg1OTA1ZWUyMmVjN2Q1YmUxZDY4YWNhMTcwOGQ5ODciLCJ0IjoiMmM0YzdkZjEtMjk4MS00N2I0LThlN2QtMWY3MmQxMDg4Y2FkIiwicyI6Ik56TTBPRGN4TVdVdE1qVTRPQzAwTmpFMUxUazJZakl0TkRNMFl6Qm1ZMkkyWlROaSJ9</string>
                </array>
                <key>RunAtLoad</key>
                <false/>
                <key>StandardOutPath</key>
                <string>/Library/Logs/com.cloudflare.cloudflared.out.log</string>
                <key>StandardErrorPath</key>
                <string>/Library/Logs/com.cloudflare.cloudflared.err.log</string>
                <key>KeepAlive</key>
                <dict>
                        <key>SuccessfulExit</key>
                        <false/>
                        <key>AfterInitialDemand</key>
                        <true/>
                </dict>
                <key>ThrottleInterval</key>
                <integer>5</integer>
        </dict>
</plist>