The homebrew mosquitto launch agent looks like this:
<?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>homebrew.mxcl.mosquitto</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mosquitto/sbin/mosquitto</string>
<string>-c</string>
<string>/usr/local/etc/mosquitto/mosquitto.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>WorkingDirectory</key>
<string>/usr/local/var/mosquitto</string>
</dict>
</plist>
Depending on your installation directory of mosquitto modify the two path strings in ProgramArguments and the path of the WorkingDirectory.
Also modify the Label to org.user.mosquitto (to avoid future conflicts with a possíble homebrew mosquitto install) and then save the file as org.user.mosquitto.plist to ~/Library/LaunchAgents/.
Load the agent with launchctl load ~/Library/LaunchAgents/org.user.mosquitto.plist
.
Under certain circumstances (the make install options which you didn't specify in your question) it may be necessary to save the plist file to /Library/LaunchAgents (instead of ~/Library/LaunchAgents), modify permissions to root:wheel 644 and start it with:
sudo launchctl load /Library/LaunchAgents/org.user.mosquitto.plist
Now you can test the installation and ensure the server is running successfully. Open a new command window and start a listener.
mosquitto_sub -t topic/state
In another window, send a message to the listener.
mosquitto_pub -t topic/state -m "Hello World"