osx - Throttling respawn messages to terminal with launchd: is this normal?

13
2014-06
  • asmeurer

    I have a launchd agent set up using the WatchPaths feature. It looks something like

    <?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.my.label</string>
        <key>LowPriorityIO</key>
        <true/>
        <key>ProgramArguments</key>
        <array>
            <string>/bin/bash</string>
            <string>-c</string>
            <string>PROGRAM HERE</string>
        </array>
        <key>QueueDirectories</key>
        <array/>
        <key>ThrottleInterval</key>
        <integer>10</integer>
        <key>WatchPaths</key>
        <array>
            <string>PATH HERE</string>
        </array>
    </dict>
    </plist>
    

    Every 10 seconds, I get a message to the console, like

    com.apple.launchd.peruser.501: (com.my.label) Throttling respawn: Will start in 10 seconds
    

    Is this normal? Will it affect my system to have these messages written to the logs every 10 seconds? There are no errors, and the agent itself seems to work just fine.

  • Answers
  • ؘؘؘ

    launchd will only start the program at most every 10 seconds. From man launchd.plist:

    ThrottleInterval <integer>
    This key lets one override the default throttling policy imposed on jobs
    by launchd.  The value is in seconds, and by default, jobs will not be
    spawned more than once every 10 seconds.  The principle behind this is
    that jobs should linger around just in case they are needed again in the
    near future. This not only reduces the latency of responses, but it
    encourages developers to amortize the cost of program invocation.
    

    If a file in WatchPaths is modified within 10 seconds from the last invocation, it's normal that the job gets throttled. Setting ThrottleInterval to a value below 10 has no effect.

    If you want to remove those log messages, add something like sleep 10 to the end of the program.


  • Related Question

    osx - Creating a Mac OS X launchd plist for vpnd
  • michaelmichael

    I need to create a launchd plist that causes vpnd to launch at startup. vpnd works fine when invoked from the command line, but I can't figure out how to make a plist that does the same thing. Can anyone help? Here's what I've cobbled together so far:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
     <key>Label</key>
     <string>com.apple.ppp.l2tp</string>
     <key>OnDemand</key>
     <false/>
     <key>Program</key>
      <string>/usr/sbin/vpnd</string>
     <key>ProgramArguments</key>
      <array>
       <string>vpnd</string>
      </array>
     <key>RunAtLoad</key>
     <true/>
    </dict>
    </plist>
    

    Running it with launchctl -w has no effect, triggers no errors, and outputs nothing to the console. Does the XML look right?


  • Related Answers
  • Steve Folly

    I grabbed this from a 10.4 server...

    /System/Library/LaunchDaemons/com.apple.ppp.l2tp.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.apple.ppp.l2tp</string>
        <key>OnDemand</key>
        <false/>
        <key>Program</key>
        <string>/usr/sbin/vpnd</string>
        <key>ProgramArguments</key>
        <array>
            <string>vpnd</string>
            <string>-x</string>
            <string>-i</string>
            <string>com.apple.ppp.l2tp</string>
        </array>
        <key>ServiceIPC</key>
        <false/>
    </dict>
    </plist>