Difference between revisions of "Launchd"

From Wasya Wiki
Jump to: navigation, search
(Startup Scripts)
Line 53: Line 53:
 
  sudo launchctl unload -w /Library/LaunchAgents/com.mongodb.mongodb.plist  
 
  sudo launchctl unload -w /Library/LaunchAgents/com.mongodb.mongodb.plist  
 
  sudo launchctl load -w /Library/LaunchAgents/com.mongodb.mongodb.plist
 
  sudo launchctl load -w /Library/LaunchAgents/com.mongodb.mongodb.plist
 +
 +
 +
== Troubleshooting ==
 +
=== /Users/piousbox/Library/LaunchAgents/homebrew.mxcl.postgresql.plist: Path had bad ownership/permissions ===
 +
sudo chown root:wheel homebrew.mxcl.postgresql.plist

Revision as of 17:23, 20 September 2018

Startup Scripts

From: https://medium.com/@fahimhossain_16989/adding-startup-scripts-to-launch-daemon-on-mac-os-x-sierra-10-12-6-7e0318c74de1

Agent is run on behalf of the logged in user while a daemon runs on behalf of the root

/Library/LaunchAgents/com.mongodb.mongodb.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.mongodb.mongodb</string> <!-- org.mongodb.mongodb perhaps? -->
    <key>OnDemand</key>
    <false/>
    <key>Disabled</key>
    <false />
    <key>UserName</key>
    <string>piousbox</string>
    <key>GroupName</key>
    <string>wheel</string>
    <key>ProgramArguments</key>
    <array>
            <string>/usr/local/lib/mongodb/bin</string>
    </array>
</dict>
</plist>

Another example:

<?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.piousbox.mysql</string>
    <key>ProcessType</key>       <string>Interactive</string>
    <key>Disabled</key>          <false/>
    <key>RunAtLoad</key>         <true/>
    <key>KeepAlive</key>         <true/>
    <key>SessionCreate</key>     <true/>
    <key>LaunchOnlyOnce</key>    <false/>
    <key>ExitTimeOut</key>       <integer>600</integer>
    <key>Program</key>           <string>/usr/local/mysql/bin/mysqld</string>
    <key>WorkingDirectory</key>  <string>/usr/local/mysql</string>
</dict>
</plist>

The -w flag makes it load always on startup.

sudo launchctl unload -w /Library/LaunchAgents/com.mongodb.mongodb.plist 
sudo launchctl load -w /Library/LaunchAgents/com.mongodb.mongodb.plist


Troubleshooting

/Users/piousbox/Library/LaunchAgents/homebrew.mxcl.postgresql.plist: Path had bad ownership/permissions

sudo chown root:wheel homebrew.mxcl.postgresql.plist