How to run godoc under launchd on OS X
How to run godoc under launchd on OS X
godoc is an amazing reference utility. I use launchd to keep it running for me.
<?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>org.golang.godoc</string> <key>ProgramArguments</key> <array> <!-- ensure this is the absolute path to your godoc install --> <string>/Users/dave/go/bin/godoc</string> <string>-http=127.0.0.1:6060</string> </array> <key>Sockets</key> <dict> <key>Listeners</key> <dict> <key>SockServiceName</key> <string>6060</string> </dict> </dict> <key>RunAtLoad</key> <false/> </dict> </plist>
Place this file in ~/Library/LaunchAgents/org.golang.godoc.plist
and edit the absolute path to your godoc binary. Then issue the command
$ launchctl load ~/Library/LaunchAgents/org.golang.godoc.plist
You can then browse to http://127.0.0.1:6060 to view the current documentation for your Go installation.
To stop godoc just issue a killall godoc and launchd will restart it when necessary. You can use the same command after updating to the latest release to ensure you’re viewing the most up to date documentation.
——–我是分割线———–
launchctl不是特别友好,用load加载plist文件时,只会报告出错了,但不会告诉你出了什么错误,今天折腾了半天,才发现是格式问题,漏了一个?号。
原作中貌似没提用start启动,以本文为例,启动godoc需要使用start命令: launchctl start org.golang.godoc
不知道为什么启动godoc还要配置SocketService,看别人配置redis也没指定,结果照着redis配置,一直没启动,好在有人写了现成的。找个机会看下plist的详细格式要去。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。