How to run godoc under launchd on OS X

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。

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的詳細格式要去。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.