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.

<!-- lang: xml -->
<?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][1] 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的详细格式要去。 [1]: http://127.0.0.1:6060

转载于:https://my.oschina.net/bluven/blog/210262

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值